25

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?

2

13 Answers 13

22

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

5
  • Unfortunately this didn't work me. Using a mac, rvm (1.92) and Snow Leopard. Commented May 12, 2011 at 12:37
  • 1
    @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
    Commented May 28, 2011 at 15:44
  • Edit i've upgraded back to 1.8.4 now. The gem pristine ... solution seems to work well
    – p3drosola
    Commented May 28, 2011 at 15:51
  • 1
    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)
    – PandaWood
    Commented Jun 23, 2014 at 2:08
  • 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 Commented Jan 29, 2020 at 12:45
19

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

5
  • the first command worked great, but the second is giving me a syntax error (Ruby 1.8.7-p249). Anyone else? Commented May 17, 2011 at 20:34
  • 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. Commented May 17, 2011 at 21:10
  • 1
    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?
    – ryenus
    Commented May 18, 2011 at 12:23
  • 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]}" Commented May 21, 2011 at 8:10
  • 4
    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]}"
    – Zubin
    Commented Aug 2, 2011 at 2:18
8

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).

1
  • 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.
    – house9
    Commented Aug 26, 2011 at 17:49
5

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
1
  • 1
    it takes a Scala guy to fix the Ruby gems properly!
    – Alexy
    Commented Aug 22, 2011 at 18:34
4

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
3

Installing rubygems version 1.8.4 gets rid of the gem spec deprecation warnings:

$ gem update --system

=== 1.8.4 / 2011-05-25

  • 1 minor enhancement:

    • Removed default_executable deprecations from Specification.
1

Run this command sudo gem pristine --all --no-extensions

to remove all those warning messages.

1

Simpler: Add the following to environment.rb

ActiveSupport::Deprecation.silenced = true
1

Preferred solution

Use this, a courtesy of gmarik's gist:

.bashrc:

if [ -d "$HOME/.ruby/lib/" ]; then
  RUBYLIB="$RUBYLIB:$HOME/.ruby/lib"
  RUBYOPT="-rno_deprecation_warnings_kthxbye"
  export RUBYLIB RUBYOPT
fi

~/.ruby/lib/no_deprecation_warnings_kthxbye.rb

begin
require 'rubygems'
Gem::Deprecate.skip = true if defined?(Gem::Deprecate)
rescue LoadError => e
  p e
end

Fall-back solution

Use it when:

  • you use RVM and keep gems in ~
  • you can't use $RUBYLIB because your IDE ignores it when running unit tests
  • you can't upgrade to the latest Rubygems because of some old, unmaintained gems in Gemfile

Modify rubygems/deprecate.rb:

def self.skip # :nodoc:
  @skip ||= true
end
1

I tried all the above options but nothing worked.

Finally, I uninstalled Ruby and all dependencies, installed RVM using the link https://rvm.io/rvm/install, and reinstalled Ruby using rvm install ruby.

Things started working fine!

0

It looks like you're ok, It is just a warning where rake-0.8.7.gemspec will not meet new standard of RubyGems.

I'm sure rake's creator will get this sync.

1
  • It's not just Rake. It affects a lot of other gems requiring them to be reinstalled if they use native code. Commented May 12, 2011 at 6:55
0

Found that it was coming from Gem::Version.correct?(nil) so grep for that

-1

SlimGems might be a solution as well.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.