如何判断哪个gem导致Rails无法启动?

时间:2011-01-27 19:26:31

标签: ruby-on-rails

尝试启动Rails 2.3.8项目时出现此错误:

nil的未定义方法`map':NilClass(NoMethodError)

我在历史上已经销售了一堆宝石,这是一个草率的项目,在environment.rb中没有相应的config.gem行。

如何恢复此项目以便可以启动它?我在供应商中拥有所有这些宝石。我想只是删除它们,启动项目,并等待失败,逐个重新添加最新版本的宝石。那可行吗?

堆栈跟踪没有帮助:

/opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/site_ruby/1.8/rubygems.rb:223:in `activate': undefined method `map' for nil:NilClass (NoMethodError)
from /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/site_ruby/1.8/rubygems.rb:249:in `activate'
from /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/site_ruby/1.8/rubygems.rb:248:in `each'
from /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/site_ruby/1.8/rubygems.rb:248:in `activate'
from /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/site_ruby/1.8/rubygems.rb:249:in `activate'
from /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/site_ruby/1.8/rubygems.rb:248:in `each'
from /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/site_ruby/1.8/rubygems.rb:248:in `activate'
from /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/site_ruby/1.8/rubygems.rb:1082:in `gem'
from ./script/../config/../vendor/rails/railties/lib/rails/gem_dependency.rb:73:in `add_load_paths'
from ./script/../config/../vendor/rails/railties/lib/initializer.rb:301:in `add_gem_load_paths'
from ./script/../config/../vendor/rails/railties/lib/initializer.rb:301:in `each'
from ./script/../config/../vendor/rails/railties/lib/initializer.rb:301:in `add_gem_load_paths'
from ./script/../config/../vendor/rails/railties/lib/initializer.rb:132:in `process'
from ./script/../config/../vendor/rails/railties/lib/initializer.rb:113:in `send'
from ./script/../config/../vendor/rails/railties/lib/initializer.rb:113:in `run'
from /Library/Illumaware/code/evokat25/config/environment.rb:19
from /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require'
from /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `require'
from /Library/Illumaware/code/evokat25/vendor/rails/activesupport/lib/active_support/dependencies.rb:156:in `require'
from /Library/Illumaware/code/evokat25/vendor/rails/activesupport/lib/active_support/dependencies.rb:521:in `new_constants_in'
from /Library/Illumaware/code/evokat25/vendor/rails/activesupport/lib/active_support/dependencies.rb:156:in `require'
from /Library/Illumaware/code/evokat25/vendor/rails/railties/lib/commands/server.rb:84
from /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require'
from /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `require'
from script/server:3

2 个答案:

答案 0 :(得分:0)

完整的堆栈跟踪应该包含抛出此异常的源文件和行号。

Stacktrace可以在命令提示符下,启动rails项目时,也可以在网页上。

答案 1 :(得分:0)

我通过环境.rb文件中的config.gem行的试错编辑找到了罪魁祸首。