Ruby-on-rails Gem.source_index 已弃用,请使用规范。我应该重新安装 Gem 还是 Rails?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/6065383/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-03 01:11:14  来源:igfitidea点击:

Gem.source_index is deprecated, use Specification. Should I re-install Gem or Rails?

ruby-on-railsrubydeprecated

提问by Kevin H

I'm learning RoR on Ubuntu 11. Got the following message when I was trying to generate an app. Did I install something incorrectly?

我正在 Ubuntu 11 上学习 RoR。当我尝试生成应用程序时收到以下消息。我是否安装了错误的东西?

$ rails generate controller Pages home contact
NOTE: Gem.source_index is deprecated, use Specification. It will be removed on or after 2011-11-01.
Gem.source_index called from /usr/lib/ruby/gems/1.8/gems/bundler-1.0.12/lib/bundler/shared_helpers.rb:3.
NOTE: Gem.source_index is deprecated, use Specification. It will be removed on or after 2011-11-01.
Gem.source_index called from /usr/lib/ruby/gems/1.8/gems/bundler-1.0.12/lib/bundler/source.rb:162.
NOTE: Gem::SourceIndex#each is deprecated with no replacement. It will be removed on or after 2011-11-01.
Gem::SourceIndex#each called from /usr/lib/ruby/gems/1.8/gems/bundler-1.0.12/lib/bundler/source.rb:162.
NOTE: Gem.source_index is deprecated, use Specification. It will be removed on or after 2011-11-01.
Gem.source_index called from /usr/lib/ruby/gems/1.8/gems/bundler-1.0.12/lib/bundler/shared_helpers.rb:84.

回答by dsaronin

This worked for me: downgrade rubygems:

这对我有用:降级rubygems:

gem update --system 1.6.2

found this advice at: Gem.source_index is deprecated, use Specification #34

在以下位置找到此建议:不推荐使用 Gem.source_index,请使用规范 #34

回答by dexter

Try this:

尝试这个:

sudo gem update bundler

This will update bundler to most recent version (currently 1.0.15). This will not generate the warning or at least in my case this was the cause of the warning.

这会将 bundler 更新到最新版本(当前为 1.0.15)。这不会产生警告,或者至少在我的情况下这是警告的原因。

回答by Koraktor

The best way to solve this is:

解决这个问题的最好方法是:

$ gem pristine --all --no-extensions

This will rebuild all gems (excluding those with native extensions) and update their gemspecs. If you don't have any gems with native extensions or you didn't use any custom compile flags on those gems you can also omit the --no-extensionsflag. Otherwise you'll have to build them seperately.

这将重建所有 gems(不包括具有本机扩展的那些)并更新它们的 gemspecs。如果您没有任何带有本机扩展的 gem,或者您没有在这些 gem 上使用任何自定义编译标志,您也可以省略该--no-extensions标志。否则,您将不得不单独构建它们。

回答by Kevin H

I tried "sudo gem update". After that, I don't see the message "Gem.source_index is deprecated, use Specification..." anymore. Yay!

我试过“sudo gem update”。之后,我再也看不到消息“Gem.source_index 已弃用,请使用规范...”。好极了!

回答by manish nautiyal

rails -v = 2.2.2

导轨-v = 2.2.2

ruby -v = 1.8.7

红宝石-v = 1.8.7

This link helps me.

这个链接对我有帮助。

or simply do

或者干脆做

gem update --system 1.6.2