Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I fix Rubygems recent deprecation warning?

Tags:

I have recently run updates:

gem update --system gem update 

Now, I come with a lot of deprecation warnings each time I load a gem. For example, rails console:

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 /Users/user/.rvm/gems/ruby-1.9.2-p180@global/specifications/rake-0.8.7.gemspec:10. 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 /Users/user/.rvm/gems/ruby-1.9.2-p180@global/specifications/rake-0.8.7.gemspec:10. 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 /Users/user/.rvm/gems/ruby-1.9.2p180@global/specifications/rake-0.8.7.gemspec:10. Loading development environment (Rails 3.0.7) ruby-1.9.2-p180 :001 > exit 

I use RVM, Ruby 1.9.2 and Rubygems 1.8.1. Any way to get around this problem? Revert to an older version of rubygems?

like image 452
Hartator Avatar asked May 10 '11 11:05

Hartator


2 Answers

I had to downgrade to 1.6.2. Those notices are absolutely ridiculous. They make the latest version completely unusable. There should really be a way to disable them, but until then:

sudo gem update --system 1.6.2

like image 148
p3drosola Avatar answered Oct 06 '22 15:10

p3drosola


see here http://ryenus.tumblr.com/post/5450167670/eliminate-rubygems-deprecation-warnings

for short, run

gem pristine --all --no-extensions  ruby -e "`gem -v 2>&1 | grep called | sed -r -e 's#^.*specifications/##' -e 's/-[0-9].*$//'`.split.each {|x| `gem pristine #{x} -- --build-arg`}" 

if the backtick (or backquote) doesn't work for you, as @jari-jokinen has pointed out (thank you!) in some cases, replace the second line with this

ruby -e "%x(gem -v 2>&1 | grep called | sed -r -e 's#^.*specifications/##' -e 's/-[0-9].*$//').split.each {|x| %x(gem pristine #{x} -- --build-arg)}" 

Note: If your using Bundler in a production environment your offending gems will have been cached to shared/bundle so you'll need to run these commands using bundle exec

like image 34
ryenus Avatar answered Oct 06 '22 15:10

ryenus