How to avoid deprecation messages from RubyGems?
You probably need to regenerate your gem specifications.
After installing RubyGems 1.8.1 you will see deprecations when loading your exsting gems. Run gem pristine --all --no-extensions to regenerate your gem specifications safely.
http://blog.segment7.net/2011/05/05/rubygems-1-8-1
Silence deprecation warning generated from of a gem
ActiveSupport::Deprecation.silenced = true
How do I fix Rubygems recent deprecation warning?
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
How to suppress deprecation warnings?
The warning is generated by the parser before the code is evaluated. That includes your Warning.ignore
code, so the config isn't ready when the warning occurs.
You can move that code into a separate file:
# warn.rb
require 'warning'
Warning.ignore(/deprecated/)
and load it via -r
:
$ ruby -r./warn.rb -e '0 if /a/.../b/'
How can I fix a Gem deprecation Issue?
Looks like the deprecation is within rubygems itself.
Simply run this in console to update it:
gem update --system
1.8.1 gem rollback to 1.7.2 and still get some deprecation warnings
Bundler 1.0.13 (version released May 4, 2011) running with rubygems 1.7.2 issues this annoying deprecation warning:
NOTE: Gem::SourceIndex#all_gems is deprecated with no replacement. It will be removed on or after 2011-10-01.
Gem::SourceIndex#all_gems called from /Users/me/.rvm/gems/ruby-1.9.2-p180@composer/gems/bundler-1.0.13/lib/bundler/rubygems_integration.rb:256
A fix was committed on 5/11/2011 in the Bundler repo to correct an issue submitted 5/6/2011.
Pending release of Bundler 1.1, you can try this solution:
$ gem uninstall bundler
$ gem install bundler --version=1.0.12
I hope this helps. Took some digging to find it.
How to handle deprecated gem warning (SourceIndex#all_gems)?
I got the same errors for a bunch of my gems in a non-Rails environment when I upgraded to rubygems 1.8.0. I got the warnings any time rubygems is required. Looking around the 'Net, it seems like it might be a problem also with rubygems 1.7.x, but I never had one of those versions installed so I'm not sure. I fixed this by running:
gem pristine --all --no-extensions
I had to run it a few times - it kept erroring out (but usually not in the same place from run to run). Eventually it got far enough that it had addressed the majority of my gems.
There were a few gems that didn't get their specifications regenerated correctly (json and sequel, specifically in my case) because they needed to build an extension. (The gem command output indicated it was skipping them, though it was easy to miss that message amidst all the deprecation warnings.) For those gems, I uninstalled them and then reinstalled them again (they'd previously been installed by bundler in rubygems 1.5.x) and that fixed the remaining warnings. It may be that I could have started with that plan of attack originally, but I didn't try.
Suppress Ruby warnings when running specs
If you run your specs directly with the ruby command instead of the spec wrapper, you can use the -W command line option to silence warnings:
$ ruby --help
[...]
-W[level] set warning level; 0=silence, 1=medium, 2=verbose (default)
So in your case:
$ ruby -W0 -Ispec spec/models/event_spec.rb
should not show you any warnings.
Alternatively, you could set $VERBOSE=nil before your gems are loaded, ie at the top of your environment.rb (or application.rb if you're on Rails 3). Note that this disables all warnings all the time.
Or, since you are using Rails, you should be able to use Kernel.silence_warnings around the Bundler.require block if you're using Bundler:
Kernel.silence_warnings do
Bundler.require(:default, Rails.env) if defined?(Bundler)
end
More selectively, set $VERBOSE only for loading specific gems:
config.gem 'wellbehaving_gem'
original_verbosity = $VERBOSE
$VERBOSE = nil
config.gem 'noisy_gem_a'
$VERBOSE = original_verbosity
Related Topics
Error While Trying to Load the Gem 'Devise. Activesupport: Duration Can't Be Coerced into Integer
Ruby Dynamic Classes. How to Fix "Warning: Class Variable Access from Toplevel"
Printing an Ascii Spinning "Cursor" in the Console
Properly Converting a Cmyk Image to Rgb with Rmagick
Changing Field Separator/Delimiter in Exported CSV Using Ruby CSV
Is There an Equivalent to 'Array::Sample' for Hashes
Get Path to Activestorage File on Disk
Error Installing Debugger: Failed to Build Gem Native Extension with Ruby-1.9.3-P362
Param Is Missing or the Value Is Empty: User Rails 4
Differences Between Proc and Lambda
Failed to Build Gem Native Extension
Fastest Way to Check If a String Matches a Regexp in Ruby
Failed to Build Gem Native Extension' on Windows 7 (The System Cannot Find the Path Specified)
Render an Erb Template with Values from a Hash
Why Does Ruby on Rails Use Http://0.0.0.0:3000 Instead of Http://Localhost:3000
Rails Link_To External Site, Url Is Attribute of User Table, Like: @Users.Website