-->

未定义的方法`source_index”的宝石:模块(NoMethodError)(undefine

2019-07-21 08:34发布

我运行一个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(滑轨:: 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

所以,真的不知道该怎么做。 希望我能得到一些快速帮助。 谢谢!

Answer 1:

我只是碰到了这个问题,我尝试从REE 1.8.7的较旧的Rails应用程序升级到1.9.3-P385。 奇怪的是,红宝石1.9.3-P327的工作就好了。 它归结为是红宝石1.9.3-P385已经安装的RubyGems版本2.0.2对我来说,和1.9.3-P327已安装的RubyGems v1.8.23。

Gem.source_index已弃用了一段时间,但由于Rails的2.3是没有得到,除了关键的安全补丁的任何更新,这将永远不会得到修复。 RubyGems的2.0版终于卸下的方法。 降级到任何rubygems之前的版本2.0.0,像25年8月1日获得功能回到现在。 您可以使用获得兼容版本gem update --system 1.8.25

作为一个非常重要的一边,Rails的2.3.5需要进行更新,以最小的2.3.17。 有迹象表明,打开你到一些非常下流的攻击关键的安全漏洞。 从长远来看,需要升级到3.X被认为是一个非常强烈的需求。



Answer 2:

RVM的用户,

rvm install rubygems 1.8.2 --force


Answer 3:

这帮助了我: http://djellemah.com/blog/2013/02/27/rails-23-with-ruby-20/

我这样做结合gem update --system 1.8.25 ,这可能不是需要为你的情况。



文章来源: undefined method `source_index' for Gem:Module (NoMethodError)