gem和/或Ruby on Rails突然爆发,有谁知道发生了什么?

我有一个曾经工作的Ruby on Rails应用程序。 我在一个月左右没用过它,但是今天尝试使用rails s启动它并得到以下错误 – 事实上,当我尝试rails -hrails -v甚至gem -h时我收到此错误或sudo gem update --system或任何与gem事情。

 NOTE: Gem::Specification#default_executable= is deprecated with no replacement. It will be removed on or after 2011-10-01. Gem::Specification#default_executable= called from /Library/Ruby/Gems/1.8/specifications/rubygems-update-1.8.2.gemspec:11. Invalid gemspec in [/Library/Ruby/Gems/1.8/specifications/tilt-1.3.3.gemspec]: invalid date format in specification: "2011-08-25 00:00:00.000000000Z" NOTE: Gem::Specification#default_executable= is deprecated with no replacement. It will be removed on or after 2011-10-01. Gem::Specification#default_executable= called from /Users/me/.gem/ruby/1.8/specifications/json-1.5.1.gemspec:10. /Library/Ruby/Site/1.8/rubygems/specification.rb:277:in `_resort!': undefined method `name' for nil:NilClass (NoMethodError) from /Library/Ruby/Site/1.8/rubygems/specification.rb:276:in `sort!' from /Library/Ruby/Site/1.8/rubygems/specification.rb:276:in `_resort!' from /Library/Ruby/Site/1.8/rubygems/specification.rb:270:in `_all' from /Library/Ruby/Site/1.8/rubygems/specification.rb:402:in `each' from /Library/Ruby/Site/1.8/rubygems/dependency.rb:216:in `find_all' from /Library/Ruby/Site/1.8/rubygems/dependency.rb:216:in `matching_specs' from /Library/Ruby/Site/1.8/rubygems/dependency.rb:238:in `to_specs' from /Library/Ruby/Site/1.8/rubygems/dependency.rb:256:in `to_spec' from /Library/Ruby/Site/1.8/rubygems.rb:1182:in `gem' from /usr/bin/rails:18 

任何人都知道发生了什么以及如何解决它? 如何卸载它并重新安装(无需卸载我的操作系统,真的很糟糕的人)

我会尝试通过运行来清理所有已安装的gem

 rm -rf ~/.gems sudo rm -rf /Library/Ruby/Gems/* 

在此gem list应列出没有gem。 然后跑

 sudo gem update --system 

确保Ruby Gems处于最新版本。 然后,您将不得不重新安装所有gem。 (可能是gem install bundler然后是bundle install )。

顺便说一下,你应该检查rbenv或rvm来管理Ruby版本,并保持所有开发gem与系统Ruby分开。

gem update --system应该解决你。 那将安装最新版本的RubyGems。

我在XCode 4.3上遇到了同样的问题。 试试这个:

打开XCode>首选项>下载>安装命令行工具

最后在终端运行:

 rvm install 1.9.3 --with-gcc=clang 

我用jquery-rails 2.0.3得到了同样的错误:

 Invalid gemspec in [C:/Ruby187/lib/ruby/gems/1.8/specifications/jquery-rails-2.0.3.gemspec]: invalid date format in specification: "2012-08-16 00:00:00.000000000Z" 

为了解决这个问题,我编辑了文件C:/Ruby187/lib/ruby/gems/1.8/specifications/jquery-rails-2.0.3.gemspec并更改包含以下内容的行:

 s.date = %q{2012-08-16 00:00:00.000000000Z} 

 s.date = %q{2012-08-16} 

然后再次运作。