【问题标题】:"NameError: undefined local variable or method 'config' for main:Object" when trying to set Vagrant proxy“NameError: undefined local variable or method 'config' for main:Object”尝试设置 Vagrant 代理时
【发布时间】:2018-08-03 18:02:53
【问题描述】:

我对 Vagrant 很陌生(昨天刚安装)。我正在尝试按照this answer 设置我的代理设置。我已经安装了proxyconf 插件。

我正在运行 Windows 7 64 位。我假设有问题的VagrantfileC:\Users\<my username>\.vagrant.d\Vagrantfile。该文件不存在,因此我将其内容设置为上面链接的答案中给出的三行(当然yourproxy 替换为我的实际代理):

config.proxy.http     = "http://yourproxy:8080"
config.proxy.https    = "http://yourproxy:8080"
config.proxy.no_proxy = "localhost,127.0.0.1"

现在我正在尝试运行 Vagrant 命令(我从另一个在线教程中获得)

vagrant box add bento/centos-7 --provider=virtualbox

当我运行它时,我得到以下信息:

There was an error loading a Vagrantfile. The file being loaded
and the error message are shown below. This is usually caused by
a syntax error.

Path: C:/Users/<my username>/.vagrant.d/Vagrantfile
Line number: 0
Message: NameError: undefined local variable or method `config' for main:Object

很抱歉,这可能是由于我对 Vagrant 的了解极其有限,但是有人可以帮助我如何正确设置它吗?

【问题讨论】:

    标签: vagrant


    【解决方案1】:

    需要在这些行之前放置Vagrant.configure("2") do |config|,在它们之后放置end。这是我引用的答案中遗漏的。

    【讨论】:

      猜你喜欢
      • 2017-12-05
      • 1970-01-01
      • 2017-05-30
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多