How do I fix Rubygems recent deprecation warning?
Solution 1
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
Solution 2
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
Solution 3
You can also use the more RVM specific rvm rubygems current
to get back to a safer version of gem (1.6.2 right now).
Solution 4
I took other peoples' answers and scriptified them into something a little more worky for me. I still had to delete a couple by hand out of /usr/local/cellar.
#!/usr/bin/env bash
#
brew install gnu-sed
sudo gem pristine --all --no-extensions
gems=$(gem -v 2>&1 | grep called | gsed -r -e 's#^.*specifications/##' -e 's/-[0-9].*$//')
for gem in $gems
do
echo Fixing $gem...
sudo gem pristine $gem -- -build-arg
done
Solution 5
I can confirm that 1.8.10 has removed these deprecation warnings in a Rails 3.1 environment as well.
Simply run
gem update --system
Related videos on Youtube
Comments
-
Hartator almost 2 years
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?
-
iceydee almost 13 yearsYou need to provide more information, what does your Gemfile look like?
-
fl00r almost 13 yearspossible duplicate of How to avoid deprecation messages from RubyGems?
-
-
PJP almost 13 yearsIt's not just Rake. It affects a lot of other gems requiring them to be reinstalled if they use native code.
-
Jack Kinsella almost 13 yearsUnfortunately this didn't work me. Using a mac, rvm (1.92) and Snow Leopard.
-
Aidan Feldman almost 13 yearsthe first command worked great, but the second is giving me a syntax error (Ruby 1.8.7-p249). Anyone else?
-
markquezada almost 13 yearsI had a syntax error on the second line also so I just did it by hand. Check the output of
gem -v 2>&1 | grep called
and for each of the gems returned by that command, dogem pristine GEM_NAME_HERE -- --build-arg
. You might need to usesudo
also. -
ryenus almost 13 yearshmmm, @aidan-feldman, @mirthlab, may I ask what kind of syntax error was that? I don't think there's any ruby 1.9 only feature used on the second line, possibly missing sed or sudo?
-
Jari Jokinen almost 13 yearsBackticks didn't work with Ruby Enterprise Edition 2011.03 (1.8.7) and/or Bash 4.1.5(1) so I just replaced them with %x[] like 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]}"
-
p3drosola almost 13 years@mr-walinzi I'm not sure to be honest. I just want to develop my rails app in peace, and i can do that with 1.6.2
-
p3drosola almost 13 yearsEdit i've upgraded back to 1.8.4 now. The
gem pristine ...
solution seems to work well -
Zubin almost 13 yearsOSX/BSD systems will get a
sed: illegal option -- r
because sed uses different flags. Instead replace-r
with-E
, ie:ruby -e "%x[gem -v 2>&1 | grep called | sed -E -e 's#^.*specifications/##' -e 's/-[0-9].*$//'].split.each {|x| %x[gem pristine #{x} -- --build-arg]}"
-
Alexy over 12 yearsit takes a Scala guy to fix the Ruby gems properly!
-
house9 over 12 yearsThanks! -> in my case I was using rvm with ruby-1.8.7-p302, running current still gave me rubygems 1.8.6 with all of its warnings;
rvm install rubygems 1.6.2
did the trick. -
Igor Mironenko almost 10 yearsRolling back is always going to introduce it's own problems - for me, this command doesn't work anyway - on ruby 1.9.1 rubygems.rb:483:in
find_files': undefined method
map' for Gem::Specification:Class (NoMethodError) -
Rahul Shinde over 4 yearsI have tried to run mentioned command but it won't work. Showing below error message. Fetching rubygems-update-1.6.2.gem ERROR: While executing gem ... (Gem::FilePermissionError) You don't have write permissions for the /usr/bin directory