【问题标题】:homestead.rb:63:in `configure': undefined method `each' for nil:NilClass (NoMethodError)homestead.rb:63:in `configure': nil:NilClass (NoMethodError) 的未定义方法`each'
【发布时间】:2015-01-12 16:04:51
【问题描述】:

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

C:/Users/Renz/code/Homestead/scripts/homestead.rb:63:in configure': undefined m ethodeach' for nil:NilClass (NoMethodError) 来自 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' 来自 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 级) 加载中' 来自 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' 来自 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' 来自 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:in vagrantfile' from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.6.5/lib/vagrant/e nvironment.rb:399:inhost' 来自 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 动作/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:in unload' from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.6.5/bin/vagrant:1 77:inensure in ' 来自 C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.6.5/bin/vagrant:1 77:在`'

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

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

【问题讨论】:

  • 我遇到了同样的问题,我的问题是 homestead.yaml 中的文件夹和站点配置,所以也许您想向我们展示您的文件,以便我们尝试找出问题...

标签: laravel vagrant configure


【解决方案1】:

您需要在 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

【讨论】:

  • 太棒了!谢谢!不太明显的情况发生在尝试vagrant up 作为缺少.homestead 目录且其中包含Homestead.yaml 的用户时。我很惊讶“.homestead 目录在您的主目录中不存在,如果存在,它缺少定义至少一个数据库的有效Homestead.yaml 文件。”跨度>
  • 还有一点需要注意 - 如果您的 .homestead 目录位于映射的网络驱动器上,请确保您的系统仍然映射了该驱动器。我刚刚遇到了一个问题,尝试vagrant up 失败并出现此错误并且当时我自己不知道,我的.homestead 的网络驱动器不再映射到我的用户。一旦我意识到发生了什么,一个快速简单的修复,所以有人可以通过早点检查来节省一些挫败感!
  • 或者只是删除数据库块
【解决方案2】:

当你的 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

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

【讨论】:

    【解决方案3】:

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

    请确保您输入了:

    init.bat
    

    问候!

    【讨论】:

      猜你喜欢
      • 2016-01-29
      • 1970-01-01
      • 2013-11-14
      • 2013-01-14
      • 2017-10-02
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多