gem 和/或 Ruby on Rails 突然崩溃了,有人知道发生了什么吗?

2024-03-10

我有一个 Ruby on Rails 应用程序,曾经可以工作。我已经有一个月左右没有使用它了,但今天尝试启动它rails s并收到以下错误 - 事实上,当我尝试时,我收到此错误rails -h or rails -v甚至gem -h or 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不应列出任何宝石。然后运行

sudo gem update --system

确保 Ruby Gems 是最新版本。然后您必须重新安装所有宝石。 (大概gem install bundler其次是bundle install).

顺便说一句,你应该检查一下rbenv https://github.com/sstephenson/rbenv or rvm https://rvm.io用于管理 Ruby 版本并将所有开发 gem 与系统 Ruby 分开。

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

gem 和/或 Ruby on Rails 突然崩溃了,有人知道发生了什么吗? 的相关文章

随机推荐