質問

I ran bundle install and it was successful. However, when I ran ruby script/server, I got a lot of messages before the server actually started:

NOTE: Gem::SourceIndex#add_spec is deprecated, use Specification.add_spec. It will be removed on or after 2011-11-01.
Gem::SourceIndex#add_spec called from /usr/local/lib/site_ruby/1.8/rubygems/source_index.rb:127.

NOTE: Gem::SourceIndex#add_spec is deprecated, use Specification.add_spec. It will be removed on or after 2011-11-01.
Gem::SourceIndex#add_spec called from /usr/local/lib/site_ruby/1.8/rubygems/source_index.rb:127.

NOTE: Gem::SourceIndex#add_spec is deprecated, use Specification.add_spec. It will be removed on or after 2011-11-01.
Gem::SourceIndex#add_spec called from /usr/local/lib/site_ruby/1.8/rubygems/source_index.rb:127.

How can I fix this?

役に立ちましたか?

解決

Looks like the deprecation is within rubygems itself.

Simply run this in console to update it:

   gem update --system

他のヒント

No one will like this, but so far, it works for me.
versions:
ruby -v #=> ruby 1.8.7 (2012-02-08 patchlevel 358) [universal-darwin11.0]
rails -v #=> Rails 2.3.5
gem -v #=> 1.8.25

The fix:
sudo vi /Library/Ruby/Site/1.8/rubygems/source_index.rb
(the file might be located elsewhere on your system, read your error message, it tells you where it is)

Change line 127 from:
add_spec gemspec if gemspec
to:
Gem::Specification.add_spec gemspec if gemspec

rubygems will now use the non-depreciated method and the warning should be gone.

Warning Will Robinson: I am a cowboy coder and have no idea what side effects this could have, but so far it works ok for me. It appears that source_index.rb file is not part of the rubygems github repository, so I am guessing it is created by some other process. I heard if you are using rails 3 this goes away. ::shrugs::

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top