Rails命令不起作用(spring gem error)

时间:2015-06-11 01:30:55

标签: ruby-on-rails ruby gem rubygems spring-gem

老实说,我很丢失。每次我尝试运行任何rails命令ie, rails g controller home时,命令行都会抛出这个错误,我不知道发生了什么。我已经卸载并重新安装spring,我也用Google搜索。

有人帮忙吗?

Johnny@Johnnys-MacBook-Pro original_skillup (feature/s3_uploader) $ rails g controller spring
/Users/Johnny/.rvm/gems/ruby-2.2.1/gems/spring-1.3.6/lib/spring/application.rb:102:in `block in preload': undefined method `[]' for nil:NilClass (NoMethodError)
  from /Users/Johnny/.rvm/gems/ruby-2.2.1/gems/spring-1.3.6/lib/spring/application.rb:102:in `map'
  from /Users/Johnny/.rvm/gems/ruby-2.2.1/gems/spring-1.3.6/lib/spring/application.rb:102:in `rescue in preload'
  from /Users/Johnny/.rvm/gems/ruby-2.2.1/gems/spring-1.3.6/lib/spring/application.rb:115:in `preload'
  from /Users/Johnny/.rvm/gems/ruby-2.2.1/gems/spring-1.3.6/lib/spring/application.rb:143:in `serve'
  from /Users/Johnny/.rvm/gems/ruby-2.2.1/gems/spring-1.3.6/lib/spring/application.rb:131:in `block in run'
  from /Users/Johnny/.rvm/gems/ruby-2.2.1/gems/spring-1.3.6/lib/spring/application.rb:125:in `loop'
  from /Users/Johnny/.rvm/gems/ruby-2.2.1/gems/spring-1.3.6/lib/spring/application.rb:125:in `run'
  from /Users/Johnny/.rvm/gems/ruby-2.2.1/gems/spring-1.3.6/lib/spring/application/boot.rb:18:in `<top (required)>'
  from /Users/Johnny/.rvm/rubies/ruby-2.2.1/lib/ruby/site_ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54:in `require'
  from /Users/Johnny/.rvm/rubies/ruby-2.2.1/lib/ruby/site_ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54:in `require'
  from -e:1:in `<main>'

谢谢!

3 个答案:

答案 0 :(得分:2)

我认为你安装了Spring gem并且控制器的名称是冲突的。

https://github.com/rails/spring

尝试更改控制器的名称。希望它有效。干杯!

答案 1 :(得分:0)

对于上一个答案,您可以拥有一个名为home的控制器(没有命名问题)。看起来您使用的弹簧宝石版本存在问题。你试过运行'捆绑安装'吗?我检查了Github上的spring gem,它看起来并不像gem有任何当前的问题。您可以删除spring gem并查看问题是否仍然存在,如果是,那么您就知道问题更深层了。

答案 2 :(得分:0)

这是spring gem中的Exception backrace问题。

https://github.com/rails/spring/pull/459

将spring更新为1.6.1