`configure': undefined method `[]' while i vagrant up my vm

情到浓时终转凉″ 提交于 2019-12-24 14:53:08

问题


i am getting the following error when vagrant up my laravel project:

$ vagrant up
/project/path/vendor/laravel/homestead/scripts/homestead.rb:4:in `configure': undefined method `[]' for false:FalseClass (NoMethodError)
    from /project/path/Vagrantfile:20:in `block in <top (required)>'
    from /usr/lib/ruby/vendor_ruby/vagrant/config/v2/loader.rb:37:in `call'
    from /usr/lib/ruby/vendor_ruby/vagrant/config/v2/loader.rb:37:in `load'
    from /usr/lib/ruby/vendor_ruby/vagrant/config/loader.rb:103:in `block (2 levels) in load'
    from /usr/lib/ruby/vendor_ruby/vagrant/config/loader.rb:97:in `each'
    from /usr/lib/ruby/vendor_ruby/vagrant/config/loader.rb:97:in `block in load'
    from /usr/lib/ruby/vendor_ruby/vagrant/config/loader.rb:94:in `each'
    from /usr/lib/ruby/vendor_ruby/vagrant/config/loader.rb:94:in `load'
    from /usr/lib/ruby/vendor_ruby/vagrant/vagrantfile.rb:28:in `initialize'
    from /usr/lib/ruby/vendor_ruby/vagrant/environment.rb:580:in `new'
    from /usr/lib/ruby/vendor_ruby/vagrant/environment.rb:580:in `vagrantfile'
    from /usr/lib/ruby/vendor_ruby/vagrant/environment.rb:365:in `host'
    from /usr/lib/ruby/vendor_ruby/vagrant/environment.rb:169:in `block in action_runner'
    from /usr/lib/ruby/vendor_ruby/vagrant/action/runner.rb:33:in `call'
    from /usr/lib/ruby/vendor_ruby/vagrant/action/runner.rb:33:in `run'
    from /usr/lib/ruby/vendor_ruby/vagrant/environment.rb:352:in `hook'
    from /usr/lib/ruby/vendor_ruby/vagrant/environment.rb:562:in `unload'
    from /usr/bin/vagrant:176:in `ensure in <main>'
    from /usr/bin/vagrant:176:in `<main>'

the error is on homestead.rb line 4:

ENV['VAGRANT_DEFAULT_PROVIDER'] = settings["provider"] ||= "virtualbox"

any idea's?

vagrant file:

require 'json'
require 'yaml'

VAGRANTFILE_API_VERSION ||= "2"
confDir = $confDir ||= File.expand_path("vendor/laravel/homestead", File.dirname(__FILE__))

homesteadYamlPath = "Homestead.yaml"
homesteadJsonPath = "Homestead.json"
afterScriptPath = "after.sh"
aliasesPath = "aliases"

require File.expand_path(confDir + '/scripts/homestead.rb')

Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
    if File.exists? aliasesPath then
        config.vm.provision "file", source: aliasesPath, destination: "~/.bash_aliases"
    end

    if File.exists? homesteadYamlPath then
        Homestead.configure(config, YAML::load(File.read(homesteadYamlPath)))
    elsif File.exists? homesteadJsonPath then
        Homestead.configure(config, JSON.parse(File.read(homesteadJsonPath)))
    end

    if File.exists? afterScriptPath then
        config.vm.provision "shell", path: afterScriptPath
    end
end

回答1:


my Homestead.yaml file was empty. I created it and everything works as intended.




回答2:


I think you are forgetting the commands:

// Mac / Linux...
bash init.sh

// Windows...
init.bat

This command copies the Homestead.yaml, after.sh and alies files to the laravel directory.



来源:https://stackoverflow.com/questions/34374481/configure-undefined-method-while-i-vagrant-up-my-vm

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!