未定义的方法`source_index'为Gem:Module(NoMethodError)
我正在运行一个Rails 2.3.5应用程序,并运行脚本/服务器时,我显示以下内容:
./script/../config/../vendor/rails/railties/lib/rails/gem_dependency.rb:21:in `add_frozen_gem_path': undefined method `source_index' for Gem:Module (NoMethodError) from ./script/../config/boot.rb:60:in `load_initializer' from ./script/../config/boot.rb:44:in `run' from ./script/../config/boot.rb:17:in `boot!' from ./script/../config/boot.rb:123 from script/server:2:in `require' from script/server:2
如果我在boot.rb(Rails :: GemDependency.add_frozen_gem_path)中注释掉第60行并运行脚本/服务器,我得到这个:
=> Booting WEBrick => Rails 2.3.5 application starting on http://0.0.0.0:3000 ./script/../config/../vendor/rails/railties/lib/rails/gem_dependency.rb:21:in `add_frozen_gem_path': undefined method `source_index' for Gem:Module (NoMethodError) from ./script/../config/../vendor/rails/railties/lib/initializer.rb:298: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 /home/developer/bigpink/config/environment.rb:13 from /home/developer/bigpink/vendor/rails/activesupport/lib/active_support/dependencies.rb:156:in `require' from /home/developer/bigpink/vendor/rails/activesupport/lib/active_support/dependencies.rb:156:in `require' from /home/developer/bigpink/vendor/rails/activesupport/lib/active_support/dependencies.rb:521:in `new_constants_in' from /home/developer/bigpink/vendor/rails/activesupport/lib/active_support/dependencies.rb:156:in `require' from /home/developer/bigpink/vendor/rails/railties/lib/commands/server.rb:84 from script/server:3:in `require' from script/server:3
所以,不知道该怎么做。 希望我能得到一些快速的帮助。 谢谢!
当我试图从REE 1.8.7升级到1.9.3-p385时,我自己碰到了这个问题。 奇怪的是,Ruby 1.9.3-p327工作得很好。 是什么让ruby-1.9.3-p385为我安装了RubyGems版本2.0.2,1.9.3-p327安装了RubyGems v1.8.23。
Gem.source_index
已经被弃用了一段时间,但由于Rails 2.3没有得到任何更新,除了关键的安全补丁,这将永远不会得到解决。 RubyGems v2.0终于删除了这个方法。 降级到2.0.0之前的任何rubygems
版本,比如1.8.25,现在就可以获得function。 您可以使用gem update --system 1.8.25
来获得兼容版本。
作为一个非常重要的部分,Rails 2.3.5需要更新到最低2.3.17。 有严重的安全漏洞可能会导致一些非常恶劣的攻击。 从长远来看,升级到3.x需要被认为是一个非常强大的需求。
对于rvm用户,
rvm install rubygems 1.8.2 --force
这帮助了我: http : //djellemah.com/blog/2013/02/27/rails-23-with-ruby-20/
我把它和gem update --system 1.8.25
结合gem update --system 1.8.25
,这可能不是你需要的。