Hartator
Hartator

Reputation: 5145

How do I fix Rubygems recent deprecation warning?

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?

Upvotes: 25

Views: 28023

Answers (13)

grosser
grosser

Reputation: 15097

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

Upvotes: 0

Bhavya Sharma
Bhavya Sharma

Reputation: 11

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!

Upvotes: 1

Nowaker
Nowaker

Reputation: 12412

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

Upvotes: 1

AndyV
AndyV

Reputation: 3741

Simpler: Add the following to environment.rb

ActiveSupport::Deprecation.silenced = true

Upvotes: 1

Felix Rabe
Felix Rabe

Reputation: 4286

SlimGems might be a solution as well.

Upvotes: -1

Branden Silva
Branden Silva

Reputation: 1406

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

Upvotes: 4

Mr. Bean
Mr. Bean

Reputation: 11

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

to remove all those warning messages.

Upvotes: 1

Jamie
Jamie

Reputation: 31

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.

Upvotes: 3

ryenus
ryenus

Reputation: 17381

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

Upvotes: 19

Joost Schuur
Joost Schuur

Reputation: 4482

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

Upvotes: 8

psp
psp

Reputation: 12158

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

Upvotes: 5

p3drosola
p3drosola

Reputation: 5875

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

Upvotes: 22

Jirapong
Jirapong

Reputation: 24256

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.

Upvotes: 0

Related Questions