首页 文章

Gem的未定义方法`source_index':模块(NoMethodError)

提问于
浏览
132

我正在运行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

所以,不确定该怎么做 . 希望我能得到一些快速的帮助 . 谢谢!

3 回答

  • 28

    我在尝试将旧的Rails应用程序从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,以便暂时恢复功能 . 您可以使用 gem update --system 1.8.25 获得兼容版本 .

    另外,Rails 2.3.5需要更新到最低2.3.17 . 有一些严重的安全漏洞可以让你受到一些非常讨厌的攻击 . 从长远来看,升级到3.x需要被视为非常强烈的需求 .

  • 292

    对于rvm用户,

    rvm install rubygems 1.8.2 --force
    
  • 24

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

    我和 gem update --system 1.8.25 一起做了这个,这可能不是你需要的 .

相关问题