Rails / Gem命令突然抛出错误

时间:2011-05-02 05:16:31

标签: ruby-on-rails gem

我正处于Ruby on Rails编码中,在过去一小时内运行了几个rails生成方法,突然出现一个新的生成命令抛出错误消息。当我试图通过rake运行我的测试时出现了类似的错误。然后在命令行上只为“rails”。然后是“gem”命令的相同错误。

所以我认为,不知何故,我打破了我的“rubygems”Gem文件?令人担忧的是,正如我在Rubymine中编写的那样,坦率地说,它远不及它!

任何人都可以帮助解释可能发生的事情,以及最佳解决方案可能是什么?现在,我将尝试重新安装Ruby,但这是一个代价高昂的解决方法,我希望避免不止一次。

错误堆栈跟踪如下所示:

C:\Users\Ben>rails
C:/dev/lang/Ruby187/lib/ruby/site_ruby/1.8/rubygems/source_index.rb:127:in `load_gems_in':
private method `load' called for Gem::Specification:Class (NoMethodError)
from C:/dev/lang/Ruby187/lib/ruby/site_ruby/1.8/rubygems/deprecate.rb:38:in `skip_during'
from C:/dev/lang/Ruby187/lib/ruby/site_ruby/1.8/rubygems/source_index.rb:126:in `load_gems_in'
from C:/dev/lang/Ruby187/lib/ruby/site_ruby/1.8/rubygems/source_index.rb:125:in `each'
from C:/dev/lang/Ruby187/lib/ruby/site_ruby/1.8/rubygems/source_index.rb:125:in `load_gems_in'
from C:/dev/lang/Ruby187/lib/ruby/site_ruby/1.8/rubygems/source_index.rb:122:in `reverse_each'
from C:/dev/lang/Ruby187/lib/ruby/site_ruby/1.8/rubygems/source_index.rb:122:in `load_gems_in'
from C:/dev/lang/Ruby187/lib/ruby/site_ruby/1.8/rubygems/source_index.rb:321:in `refresh!'
from C:/dev/lang/Ruby187/lib/ruby/site_ruby/1.8/rubygems/source_index.rb:97:in `initialize'
from C:/dev/lang/Ruby187/lib/ruby/site_ruby/1.8/rubygems.rb:1051:in `new'
from C:/dev/lang/Ruby187/lib/ruby/site_ruby/1.8/rubygems.rb:1051:in `source_index'
from C:/dev/lang/Ruby187/lib/ruby/site_ruby/1.8/rubygems.rb:243:in `activate_dep'
from C:/dev/lang/Ruby187/lib/ruby/site_ruby/1.8/rubygems.rb:236:in `activate'
from C:/dev/lang/Ruby187/lib/ruby/site_ruby/1.8/rubygems.rb:1307:in `gem'
from C:/dev/lang/Ruby187/bin/rails:18

我的Gem文件(对于上面的项目)是:

source 'http://rubygems.org'
gem 'rails', '3.0.7'
gem 'sqlite3'
gem "jquery-rails"

虽然错误发生在所有命令行实例中。

[编辑]在这个阶段我完全重新安装了ruby和rails,问题已经消失了。我保留了旧的安装目录,以防我们可以解决这个问题的底部,或者它再次出现!

[第二次编辑]新安装,在机器重启后,gem再次开始失败,而RubyMine说它找不到任何宝石(甚至是rubygems):

C:\Users\Ben>gem
C:/dev/lang/Ruby187/lib/ruby/1.8/optparse.rb:1433:in `private': undefined method `search' for class `OptionParser' (NameError)
from C:/dev/lang/Ruby187/lib/ruby/1.8/optparse.rb:1433
from C:/dev/lang/Ruby187/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:36:in `gem_original_require'
from C:/dev/lang/Ruby187/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:36:in `require'
from C:/dev/lang/Ruby187/lib/ruby/site_ruby/1.8/rubygems/command.rb:7
from C:/dev/lang/Ruby187/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:36:in `gem_original_require'
from C:/dev/lang/Ruby187/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:36:in `require'
from C:/dev/lang/Ruby187/lib/ruby/site_ruby/1.8/rubygems/command_manager.rb:7
from C:/dev/lang/Ruby187/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:36:in `gem_original_require'
from C:/dev/lang/Ruby187/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:36:in `require'
from C:/dev/lang/Ruby187/lib/ruby/site_ruby/1.8/rubygems/gem_runner.rb:7
from C:/dev/lang/Ruby187/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:36:in `gem_original_require'
from C:/dev/lang/Ruby187/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:36:in `require'
from C:/dev/lang/Ruby187/bin/gem:9

也许RubyMine搞砸了安装?还是Windows 7?我的核心开发语言不会出现问题 - 非常令人沮丧!

1 个答案:

答案 0 :(得分:0)

我的预感是正确的 - 当然,RubyMine应该受到责备......用户也是如此!

我过于习惯在Intellij for Java中使用重构工具,我在控制器中重构了一些相当常见的方法名称(例如将“show”更改为“index”)并最终重构为Ruby 1.8标准库文件!

需要仔细检查重构正在进行什么,继续进行,并尝试将其仅限于我的项目,而不是整个SDK:)