Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

gem list is showing two versions of a Ruby gem immediately after updating the gem

I just updated the mime-types gem with gem update mime-types. gem list displayed mime-types (1.16) prior to updating. After the update gem list shows mime-types (1.17.2, 1.16). Why are two version displayed?

More info: I have other Rails projects on the same computer. I have not updated the mime-types gem in any other projects. Running gem list from another project's directory (where mime-types has not been updated) displays mime-types (1.16).

like image 491
SundayMonday Avatar asked Nov 28 '11 21:11

SundayMonday


3 Answers

You have both versions installed. If you want to delete old versions (which will not always will be possible due to dependencies) use gem cleanup.

like image 57
Hauleth Avatar answered Sep 27 '22 22:09

Hauleth


Which version of RubyGems do you have? gem -v

This is interesting: I have the newest version of RubyGems but my system behaves differently:

gem list => all the gems, all the versions. No matter from where I call it.
gem list --local => same as before but user-wide.

bundle list => all the gems in a project (one version per gem)

The same goes for bundle update and gem update.

bundle update replaces the old version by the new one (the dependencies are taken care by bundler), but gem update keeps both. So if you want to keep only the newest version, run gem cleanup.

bundle outdated might be useful: it displays the outdated gems in your project (based on rubygems.org)

like image 21
Damien Avatar answered Sep 27 '22 23:09

Damien


This can happen because of gem dependencies.

For example if another gem depends on that gem, and the other gem does not have a version specified for it, and(/or) it gets updated and if its dependency on that gem's version changes... well you get the idea.
Sometimes I do a bundle and I see a ton of new versions getting downloaded. All due to changed... dependencies.

like image 32
Michael Durrant Avatar answered Sep 28 '22 00:09

Michael Durrant