Gem 报错 uninitialized constant Gem::SourceIndex,如何解决?

diguage · 2013年02月27日 · 最后由 cgyy 回复于 2013年04月11日 · 6073 次阅读

刚刚升级了一下 gem,升级方法如下: gem update --system

gem install rubygems-update update_rubygems 升级结束之后,再来一次大扫除,把老版本的 gem 清理掉 gem clean

升级详细步骤请移步: http://www.cnblogs.com/rubylouvre/archive/2009/07/19/1526648.html

但是,升级之后,运行如下命令报错:

F:\depot>rake assets:precompile
rake aborted!
uninitialized constant Gem::SourceIndex
F:/depot/config/boot.rb:6:in `<top (required)>'
F:/depot/config/application.rb:1:in `<top (required)>'
F:/depot/Rakefile:5:in `<top (required)>'
(See full trace by running task with --trace)

启动 Rails 服务器也是报错:

F:\depot>rails server
C:/Ruby193/lib/ruby/gems/1.9.1/gems/bundler-1.2.3/lib/bundler/rubygems_integration.rb:187:in `stub_source_index170': uninitialized constant Gem::SourceIndex (NameError)
        from C:/Ruby193/lib/ruby/gems/1.9.1/gems/bundler-1.2.3/lib/bundler/rubygems_integration.rb:353:in `stub_rubygems'
        from C:/Ruby193/lib/ruby/gems/1.9.1/gems/bundler-1.2.3/lib/bundler/rubygems_integration.rb:250:in `replace_entrypoints'
        from C:/Ruby193/lib/ruby/gems/1.9.1/gems/bundler-1.2.3/lib/bundler/runtime.rb:14:in `setup'
        from C:/Ruby193/lib/ruby/gems/1.9.1/gems/bundler-1.2.3/lib/bundler.rb:116:in `setup'
        from C:/Ruby193/lib/ruby/gems/1.9.1/gems/bundler-1.2.3/lib/bundler/setup.rb:7:in `<top (required)>'
        from C:/Ruby193/lib/ruby/site_ruby/1.9.1/rubygems/core_ext/kernel_require.rb:110:in `require'
        from C:/Ruby193/lib/ruby/site_ruby/1.9.1/rubygems/core_ext/kernel_require.rb:110:in `rescue in require'
        from C:/Ruby193/lib/ruby/site_ruby/1.9.1/rubygems/core_ext/kernel_require.rb:35:in `require'
        from F:/depot/config/boot.rb:6:in `<top (required)>'
        from C:/Ruby193/lib/ruby/site_ruby/1.9.1/rubygems/core_ext/kernel_require.rb:45:in `require'
        from C:/Ruby193/lib/ruby/site_ruby/1.9.1/rubygems/core_ext/kernel_require.rb:45:in `require'
        from script/rails:5:in `<main>'

请问,这是怎么回事?谁能解释一下。

刚刚用 Google 百度了一下,在 Stackoverflow 中也提到了这个问题,但是没有回答,链接如下: http://stackoverflow.com/questions/15060011/nameerror-uninitialized-constant-gemsourceindex

升级 bundler,我就是这样解决的

回滚 gem 版本 sudo gem update --system 1.6.0

需要 登录 后方可回复, 如果你还没有账号请 注册新账号