1

我正在尝试根据 Jeffery Way 教程设置一个基本的 Vagrant 实例。当我运行 vagrant 时出现此错误:

../Vagrantfile:9:in `block in <top (required)>': undefined method `box_url=' for "precise32":String (NoMethodError)
    from /Applications/Vagrant/embedded/gems/gems/vagrant-1.6.3/lib/vagrant/config/v2/loader.rb:37:in `call'
    from /Applications/Vagrant/embedded/gems/gems/vagrant-1.6.3/lib/vagrant/config/v2/loader.rb:37:in `load'
    from /Applications/Vagrant/embedded/gems/gems/vagrant-1.6.3/lib/vagrant/config/loader.rb:103:in `block (2 levels) in load'
    from /Applications/Vagrant/embedded/gems/gems/vagrant-1.6.3/lib/vagrant/config/loader.rb:97:in `each'
    from /Applications/Vagrant/embedded/gems/gems/vagrant-1.6.3/lib/vagrant/config/loader.rb:97:in `block in load'
    from /Applications/Vagrant/embedded/gems/gems/vagrant-1.6.3/lib/vagrant/config/loader.rb:94:in `each'
    from /Applications/Vagrant/embedded/gems/gems/vagrant-1.6.3/lib/vagrant/config/loader.rb:94:in `load'
    from /Applications/Vagrant/embedded/gems/gems/vagrant-1.6.3/lib/vagrant/vagrantfile.rb:28:in `initialize'
    from /Applications/Vagrant/embedded/gems/gems/vagrant-1.6.3/lib/vagrant/environment.rb:574:in `new'
    from /Applications/Vagrant/embedded/gems/gems/vagrant-1.6.3/lib/vagrant/environment.rb:574:in `vagrantfile'
    from /Applications/Vagrant/embedded/gems/gems/vagrant-1.6.3/lib/vagrant/environment.rb:359:in `host'
    from /Applications/Vagrant/embedded/gems/gems/vagrant-1.6.3/lib/vagrant/environment.rb:168:in `block in action_runner'
    from /Applications/Vagrant/embedded/gems/gems/vagrant-1.6.3/lib/vagrant/action/runner.rb:33:in `call'
    from /Applications/Vagrant/embedded/gems/gems/vagrant-1.6.3/lib/vagrant/action/runner.rb:33:in `run'
    from /Applications/Vagrant/embedded/gems/gems/vagrant-1.6.3/lib/vagrant/environment.rb:346:in `hook'
    from /Applications/Vagrant/embedded/gems/gems/vagrant-1.6.3/lib/vagrant/environment.rb:556:in `unload'
    from /Applications/Vagrant/bin/../embedded/gems/gems/vagrant-1.6.3/bin/vagrant:169:in `ensure in <main>'
    from /Applications/Vagrant/bin/../embedded/gems/gems/vagrant-1.6.3/bin/vagrant:169:in `<main>'

到目前为止,我唯一做的就是运行 vagrant init 并将“Vagrantfile”修改为如下所示:

# -*- mode: ruby -*-
# vi: set ft=ruby :

VAGRANTFILE_API_VERSION = "2"

Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|

  config.vm.box = "precise32"
  config.vm.box.box_url = "http://files.vagrantup.com/precise32.box"

end

谷歌没有提出任何关于“未定义方法'box_url ='”的信息......非常感谢任何帮助。

4

1 回答 1

1

您使用了错误的语法!它需要是这样的

config.vm.box = "precise32"
config.vm.box_url = "http://files.vagrantup.com/precise32.box"
于 2014-06-06T18:55:56.727 回答