How do I fix Rubygems recent deprecation warning?

23,988

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
Share:
23,988

Related videos on Youtube

Hartator
Author by

Hartator

My Blog : http://hartator.wordpress.com/

Updated on July 09, 2022

Comments

  • Hartator
    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?

  • PJP
    PJP almost 13 years
    It's not just Rake. It affects a lot of other gems requiring them to be reinstalled if they use native code.
  • Jack Kinsella
    Jack Kinsella almost 13 years
    Unfortunately this didn't work me. Using a mac, rvm (1.92) and Snow Leopard.
  • Aidan Feldman
    Aidan Feldman almost 13 years
    the first command worked great, but the second is giving me a syntax error (Ruby 1.8.7-p249). Anyone else?
  • markquezada
    markquezada almost 13 years
    I 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, do gem pristine GEM_NAME_HERE -- --build-arg. You might need to use sudo also.
  • ryenus
    ryenus almost 13 years
    hmmm, @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
    Jari Jokinen almost 13 years
    Backticks 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
    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
    p3drosola almost 13 years
    Edit i've upgraded back to 1.8.4 now. The gem pristine ... solution seems to work well
  • Zubin
    Zubin almost 13 years
    OSX/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
    Alexy over 12 years
    it takes a Scala guy to fix the Ruby gems properly!
  • house9
    house9 over 12 years
    Thanks! -> 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
    Igor Mironenko almost 10 years
    Rolling 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
    Rahul Shinde over 4 years
    I 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