[NOTE: This post is getting an alarming number of hits... everyone be sure and note the update at the bottom]
Another minor annoyance with a quick fix:
If you’re getting this warning:
Warning: Gem::Dependency#version_requirements is deprecated and will be removed on or after August 2010. Use #requirement
when running anything using rails (i believe this occurs in rails 2.3.4 or higher) with gems version 1.3.6, it seems like a fix will be released sometime soon.
However, if you’re not running edge rails and just want this warning to go away, you can just apply the patch, but be warned that I had to change the quoted “requirement” in gem_dependency.rb:
119 | r = Gem::Dependency.instance_methods.include?("requirement") ? super : version_requirements |
to a symbol:
119 | r = Gem::Dependency.instance_methods.include?(:requirement) ? super : version_requirements |
… not sure if that’s just a ruby 1.9 thing, didn’t feel like investigating any further. Silly warning is gone! Darn thing was cluttering up every script, test run, server start, rake task….
cheers!
UPDATE:
Seems I spoke too soon. And didn’t re-read the changelog before making this post — the commited patch is a little more reworked and *does* use the symbol. Good!
{ 6 comments… read them below or add one }
I didn’t know how to apply the committed patch, so in case others have the same problem:
curl http://github.com/rails/rails/commit/268c9040d5c3c7ed30f3923eee71a78eeece8a8a.diff | sudo patch -d /Library/Ruby/Gems/1.8/gems/rails-2.3.5/lib/rails
Just remember to switch out the directory after -d with wherever gem_dependency.rb lives on your system (it’s in the warning message). It is probably bad practice to patch your system gems, but to get rid of this warning we can make an exception
Oh, and if something goes wrong, reverse the patch with:
curl http://github.com/rails/rails/commit/268c9040d5c3c7ed30f3923eee71a78eeece8a8a.diff | sudo patch -d /Library/Ruby/Gems/1.8/gems/rails-2.3.5/lib/rails -R
good tip, thanks! –
You are right that patching system gems isn’t the safest thing in the world to do — an update might overwrite what you’ve done, or you could accidentally break something you don’t mean to. In this case, it’s a rather trivial alteration, that shouldn’t have any nasty side affects. A safer alternative may be to localize your rails gem in your /vendor directory, and apply the patch there. That way you leave your system rails untouched…
Yes. I just ignored this error for a few weeks and finally went looking for an answer and POOF! Gone.
That command from Lou worked for me just cut and paste to the command line. The only thing was that the patch was looking for gem_dependency_test.rb which my system apparently doesn’t have. I skipped patching that file and it appears to have worked fine.
Thanks for the patch.. Worked like a charm…
THANK YOU!
I used Lou’s tip, with the added step of doing “sudo ping yahoo.com” first so that I could enter the sudo password… otherwise it sorta “hangs” (in the bad way).
@Dan, “sudo ls” – shorter way to let sudo remember you