问题
I'm learning RoR on Ubuntu 11. Got the following message when I was trying to generate an app. Did I install something incorrectly?
$ 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.
回答1:
This worked for me: downgrade rubygems:
gem update --system 1.6.2
found this advice at: Gem.source_index is deprecated, use Specification #34
回答2:
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.
回答3:
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-extensions
flag. Otherwise you'll have to build them seperately.
回答4:
I tried "sudo gem update". After that, I don't see the message "Gem.source_index is deprecated, use Specification..." anymore. Yay!
回答5:
rails -v = 2.2.2
ruby -v = 1.8.7
This link helps me.
or simply do
gem update --system 1.6.2
来源:https://stackoverflow.com/questions/6065383/gem-source-index-is-deprecated-use-specification-should-i-re-install-gem-or-ra