How to avoid deprecation messages from RubyGems?

2019-01-23 16:00发布

问题:

After gem update --system, when I do something related to rubygems, I receive this message:

NOTE: Gem::Specification#default_executable= is deprecated with no replacement. It will be removed on or after 2011-10-01.

Gem::Specification#default_executable= called from /usr/lib/ruby/gems/1.8/specifications/rubygems-update-1.7.2.gemspec:11.

How can I avoid it? I've tried to remove rubygems and reinstall, but that didn't fix it.

回答1:

You probably need to regenerate your gem specifications.

After installing RubyGems 1.8.1 you will see deprecations when loading your exsting gems. Run gem pristine --all --no-extensions to regenerate your gem specifications safely.

http://blog.segment7.net/2011/05/05/rubygems-1-8-1



回答2:

Look where your rubygems are installed:

$ gem list -d rubygems

Find the deprecate.rb file there, and make the self.skip class method always return true.

or If you're using RVM, the following command will fix it:

rvm rubygems current


回答3:

Regenerating gem specifications worked for me: sudo gem pristine --all --no-extensions

See: https://github.com/rubygems/rubygems/blob/master/History.txt

You can also downgrade your version of rubygems: sudo gem update --system 1.7.1