gpt4 book ai didi

ruby-on-rails - Gem :Module (NoMethodError) 的未定义方法 `source_index'

转载 作者:行者123 更新时间:2023-12-03 04:29:15 24 4
gpt4 key购买 nike

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

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

最佳答案

我自己在尝试将旧版 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 需要被视为非常强烈的需求。

关于ruby-on-rails - Gem :Module (NoMethodError) 的未定义方法 `source_index',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15349869/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com