The problem: finding out how out of date a gem is
Recently I have been wading through several Gemfiles, deciding whether to upgrade each gem. To help me decide, I always want to know how recent (or not) the currently installed version is.
First I used
gem list --both GEMNAME:
$ gem list --both thinking-sphinx *** LOCAL GEMS *** thinking-sphinx (2.0.4, 2.0.1, 1.4.0, 1.3.16) *** REMOTE GEMS *** thinking-sphinx (2.0.7) thinking-sphinx-099 (1.3.2) thinking-sphinx-allen (188.8.131.52) thinking-sphinx-raspell (1.1.2)
But there are two problems:
- It clutters up your results with other gems you’re not interested in
- It only shows the latest remote version available
So then I tried each gem’s versions page on Rubygems.org. Here’s Thinking Sphinx’s. On the plus side it shows all the available versions but, on the down side, it doesn’t know which ones I’ve got already.
I wrote a gem command plugin called gem-versions. Install it with
gem install gem-versions and then do
gem versions GEMNAME.
$ gem versions thinking-sphinx 2.0.7 2.0.6 2.0.5 * 2.0.4 2.0.3 2.0.2 * 2.0.1 2.0.0 2.0.0.rc2 2.0.0.rc1 1.4.7 1.4.6 1.4.5 1.4.4 1.4.3 1.4.2 1.4.1 * 1.4.0 1.3.20 1.3.19 1.3.18 1.3.17 * 1.3.16 1.3.15 1.3.14 1.3.13 1.3.12 1.3.11 1.3.10 1.3.9 1.3.8 1.3.7 1.3.6 1.3.4 1.3.3 1.3.2 1.3.1 1.3.0 1.2.13 1.2.12
It shows all the available versions of the gem, and it stars the ones I already have locally. It’s easy to see how up to date my versions are.
Rubygems has supported command plugins since 1.3.2 but it would not be entirely true to say I found a massive amount of documentation on this.
I was pleasantly surprised at how little code is actually needed to put a gem command plugin together. Admittedly my
versions command doesn’t take any options and is about as simple as they come, but even gem-man is pretty straightforward.
If you’re deciding whether to upgrade a gem, and you want to see how out of date your installed versions are, use gem-versions.