2013-03-11 73 views
129

我運行一個Rails 2.3.5應用和一旦運行腳本/服務器我示出以下內容:未定義的方法`source_index」的寶石:模塊(NoMethodError)

./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 

如果我註釋掉線60在的boot.rb(滑軌:: GemDependency.add_frozen_gem_path)和運行腳本/服務器,我得到這個:

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

所以,真的不知道該怎麼做。希望我能得到一些快速的幫助。謝謝!

回答

287

我剛剛嘗試將舊版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需要被認爲是一個非常強大的需求。

+0

太謝謝你了!它工作完美。是的,謝謝,我正在升級到2.3.17,然後升級到最新的3.x. – noodleboy347 2013-03-12 21:38:44

+0

@uxp這個問題的任何提示:http://stackoverflow.com/questions/15374188/why-is-my-rake-call-causing-an-undefined-method-source-index-error/15378764 – Evolve 2013-03-13 07:03:26

+16

寶石更新 - -system 1.8.25 – mmell 2013-03-15 16:14:33

25

RVM的用戶,

rvm install rubygems 1.8.2 --force 
+1

我不得不回到1.6.2來完成這項工作。但這是需要的這個命令。 – Zane 2015-02-28 22:50:32

相關問題