gem and/or Ruby on Rails broke all of a sudden, anyone know what happened?

我的梦境 提交于 2019-12-21 02:59:41

问题


I had a Ruby on Rails app that used to work. I hadn't used it in a month or so, but then tried starting it up today with rails s and got the following error—in fact, I get this error when I try rails -h or rails -v or even gem -h or sudo gem update --system or anything having to do with 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

Anyone know what's going on and how to fix it? How can I uninstall it all and reinstall it (without uninstalling my OS, man that would really suck)


回答1:


I'd try cleaning out all your installed gems by running

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

After this gem list should list no gems. Then run

sudo gem update --system

to ensure Ruby Gems is at the latest version. You'll then have to reinstall all your gems. (Probably gem install bundler followed by bundle install).

By the way, you should check out rbenv or rvm for managing Ruby versions and keeping all your development gems separate from the system Ruby.




回答2:


gem update --system should fix you up. That will install the latest version of RubyGems.




回答3:


I had the same problem with XCode 4.3. Try this:

Open XCode > Preferences > Downloads > Install Command Line Tools

Finally run in the terminal:

rvm install 1.9.3 --with-gcc=clang



回答4:


I got the same error with 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"

To fix that, I have edited the file C:/Ruby187/lib/ruby/gems/1.8/specifications/jquery-rails-2.0.3.gemspec and change the line containing:

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

to

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

then it works again.



来源:https://stackoverflow.com/questions/7700776/gem-and-or-ruby-on-rails-broke-all-of-a-sudden-anyone-know-what-happened

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!