`configure':未定义的方法`[]',而我流浪了我的虚拟机 [英] `configure': undefined method `[]' while i vagrant up my vm

查看:24
本文介绍了`configure':未定义的方法`[]',而我流浪了我的虚拟机的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我的 laravel 项目无家可归时,我收到以下错误:

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>'

错误在 homestead.rb 第 4 行:

the error is on homestead.rb line 4:

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

有什么想法吗?

流浪文件:

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

推荐答案

我的 Homestead.yaml 文件是空的.我创建了它,一切都按预期工作.

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

这篇关于`configure':未定义的方法`[]',而我流浪了我的虚拟机的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆