laravel homestead.rb:63:in `configure': 未定义方法 `each' 为 nil:NilClass (NoMethodError)

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/26943977/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-14 10:25:43  来源:igfitidea点击:

homestead.rb:63:in `configure': undefined method `each' for nil:NilClass (NoMethodError)

laravelvagrantconfigure

提问by Renz

I followed how to install Laravel but after all when I entered "vagrant up" i get these errors:

我遵循了如何安装 Laravel 但毕竟当我输入“vagrant up”时,我收到了这些错误:

C:/Users/Renz/code/Homestead/scripts/homestead.rb:63:in configure': undefined m ethodeach' for nil:NilClass (NoMethodError) from C:/Users/Renz/code/Homestead/Vagrantfile:9:in block in <top (requi red)>' from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.6.5/lib/vagrant/c onfig/v2/loader.rb:37:incall' from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.6.5/lib/vagrant/c onfig/v2/loader.rb:37:in load' from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.6.5/lib/vagrant/c onfig/loader.rb:103:inblock (2 levels) in load' from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.6.5/lib/vagrant/c onfig/loader.rb:97:in each' from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.6.5/lib/vagrant/c onfig/loader.rb:97:inblock in load' from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.6.5/lib/vagrant/c onfig/loader.rb:94:in each' from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.6.5/lib/vagrant/c onfig/loader.rb:94:inload' from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.6.5/lib/vagrant/v agrantfile.rb:28:in initialize' from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.6.5/lib/vagrant/e nvironment.rb:614:innew' from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.6.5/lib/vagrant/e nvironment.rb:614:in vagrantfile' from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.6.5/lib/vagrant/e nvironment.rb:399:inhost' from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.6.5/lib/vagrant/e nvironment.rb:198:in block in action_runner' from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.6.5/lib/vagrant/a ction/runner.rb:33:incall' from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.6.5/lib/vagrant/a ction/runner.rb:33:in run' from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.6.5/lib/vagrant/e nvironment.rb:386:inhook' from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.6.5/lib/vagrant/e nvironment.rb:596:in unload' from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.6.5/bin/vagrant:1 77:inensure in ' from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.6.5/bin/vagrant:1 77:in `'

C:/Users/Renz/code/Homestead/scripts/homestead.rb:63:in configure': undefined m ethodeach' for nil:NilClass (NoMethodError) from C:/Users/Renz/code/Homestead/Vagrantfile:9:in block in <top (requi red)>' from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.6.5/lib/vagrant/c onfig/v2/loader.rb:37:incall' from C :/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.6.5/lib/vagrant/c onfig/v2/loader.rb:37:in load' from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.6.5/lib/vagrant/c onfig/loader.rb:103:inblock (2 levels) in load' from C:/HashiCorp/Vagrant/ Embedded/gems/gems/vagrant-1.6.5/lib/vagrant/c onfig/loader.rb:97:in each' from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.6.5/lib/vagrant/c onfig/loader.rb:97:inblock in load' from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.6.5/ lib/vagrant/c onfig/loader.rb:94:in each' from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.6.5/lib/vagrant/c onfig/loader.rb:94:inload' from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.6.5/lib/vagrant/v agrantfile.rb:28:in initialize' from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.6.5/lib/vagrant/e nvironment.rb:614:innew'来自 C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.6.5/lib/vagrant/e nvironment.rb:614:invagrantfile' from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.6.5/lib/vagrant/e nvironment.rb:399:in主机'来自 C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.6.5/lib/vagrant/e nvironment.rb:198:in block in action_runner' from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.6.5/lib/vagrant/a ction/runner.rb:33:incall' 来自 C:/HashiCorp/Vagrant/embedded/gems/gems/ vagrant-1.6.5/lib/vagrant/a ction/runner.rb:33:in run' from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.6.5/lib/vagrant/e nvironment.rb:386:inhook' 来自 C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.6.5/lib/vagrant/e nvironment.rb :596:inunload' from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.6.5/bin/vagrant:1 77:in确保来自 C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.6.5/bin/vagrant:1 77:in ''

i tried re-installing multiple times but still get the same error.

我尝试重新安装多次,但仍然出现相同的错误。

Please help, I really need to fix this now. Appreciate it, thanks.

请帮忙,我现在真的需要解决这个问题。欣赏,谢谢。

回答by Jon McEroy

You need to have a database added to your Homestead.yaml:

您需要在 Homestead.yaml 中添加一个数据库:

---
ip: "192.168.10.10"
memory: 2048
cpus: 1

authorize: ~/.ssh/id_rsa.pub

keys:
    - ~/.ssh/id_rsa

folders:
    - map: ~/Code/testprogram
      to: /home/vagrant/testprogram

sites:
    - map: test.app
      to: /home/vagrant/test/public

databases:
    - name: testprogram

variables:
    - key: APP_ENV
      value: local

回答by freddyiniguez

I am not pretty familiar how initialization of the Homestead environment works on Windows, but this kind of error appears when you try to run the vagrant machine without initialize the environment before.

我不太熟悉 Homestead 环境的初始化在 Windows 上是如何工作的,但是当您尝试在没有初始化环境的情况下运行 vagrant 机器时会出现这种错误。

Just be sure you typed:

只要确保你输入:

init.bat

Regards!

问候!

回答by Seyed Hussein Mirzaki

It happens when your Homestead.yamel file is like this

当你的 Homestead.yamel 文件是这样的时候就会发生

---
ip: "192.168.10.10"
memory: 2048
cpus: 1

authorize: ~/.ssh/id_rsa.pub

keys:
    - ~/.ssh/id_rsa

folders:
    - map: ~/Code/testprogram
      to: /home/vagrant/testprogram

sites:
    - map: test.app
      to: /home/vagrant/test/public
ports: < This line should be comment too<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
#   - send: 80
#     to: 80

if you comment that line or delete it the it should work fine

如果您评论该行或删除它,它应该可以正常工作