Gem:Module 的未定义方法 `source_index' (NoMethodError) [英] undefined method `source_index' for Gem:Module (NoMethodError)

查看:68
本文介绍了Gem:Module 的未定义方法 `source_index' (NoMethodError)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在运行 Rails 2.3.5 应用程序,并在运行脚本/服务器时显示以下内容:

I'm running a Rails 2.3.5 application and upon running script/server I am shown the following:

./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 行并运行脚本/服务器,我会得到:

If I comment out line 60 in boot.rb (Rails::GemDependency.add_frozen_gem_path) and run script/server, I get this:

=> 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

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

So, not really sure what to do. Hoping I can get some quick help. Thanks!

推荐答案

我自己在尝试将旧的 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.

I just ran into this problem myself while trying to upgrade an older Rails app from REE 1.8.7 to 1.9.3-p385. Oddly, Ruby 1.9.3-p327 works just fine. What it came down to was ruby-1.9.3-p385 had installed RubyGems version 2.0.2 for me, and 1.9.3-p327 has RubyGems v1.8.23 installed.

Gem.source_index 已经被弃用了一段时间,但是由于 Rails 2.3 除了关键的安全补丁之外没有得到任何更新,这永远不会得到修复.RubyGems v2.0 最终删除了该方法.降级到 2.0.0 之前的任何 rubygems 版本,例如 1.8.25 以暂时恢复功能.您可以使用 gem update --system 1.8.25 获得兼容版本.

Gem.source_index has been deprecated for a while, but since Rails 2.3 is not getting any updates except critical security patches, this will never get fixed. RubyGems v2.0 finally removed that method. Downgrade to any rubygems version prior to 2.0.0, like 1.8.25 to get the functionality back for now. You can get a compatible version using gem update --system 1.8.25.

除此之外非常重要的是,Rails 2.3.5 需要更新到至少 2.3.17.有一些严重的安全漏洞会让您面临一些非常讨厌的攻击.从长远来看,升级到 3.x 需要被视为非常强烈的需求.

As a very important aside, Rails 2.3.5 needs to be updated to a minimum of 2.3.17. There are critical security vulnerabilities that open you up to some very nasty attacks. In the long term, upgrading to 3.x needs to be considered a very strong need.

这篇关于Gem:Module 的未定义方法 `source_index' (NoMethodError)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆