Hacker Spaces

Rails: Compare installed Gems

A difficult issue with Rails is managing the installed gems between development and production environment.

Here is a little method i found to solve my gem comparison problems when i have a lot of different gems, let’s say between my development machine and the production environment at say DreamHost.

First I collect the installed gems on both machines:

[penguins]$ gem list –local > /tmp/dh.gem

devmachine:~/dev/web/ $ gem list –local > /tmp/a.gems

 

Then get this on the same machine (by scp) and run:

cat /tmp/*.gem | cut -d” ” -f1 | while read a; do  echo $a; grep $a /tmp/*.gem; echo ; done | more

This will produce a nice diff of all gems:

$ cat /tmp/*.gem | cut -d” ” -f1 | while read a; do  echo $a; grep $a /tmp/*.gem; echo ; done | more
abstract
/tmp/a.gem:abstract (1.0.0)
/tmp/dh.gem:abstract (1.0.0)

actionmailer
/tmp/a.gem:actionmailer (3.0.8, 3.0.7, 2.3.12, 2.3.11, 2.3.8, 2.3.5, 1.3.6)
/tmp/dh.gem:actionmailer (3.0.3, 2.3.8, 2.3.5, 2.3.4, 2.3.3, 2.2.2, 2.1.2, 2.1.1, 2.1.0, 2.0.5, 2.0.2)

 

Leave a Reply