RubyGems management
fire0# gem list | wc -l
36
This is not one of those “big” servers with hundred of applications: There are only three of them and those 36 gems are dependencies to keep everything running. I am not even counting their multiple installed versions. This is a normal situation that happen quite often when developing new applications – gems get tested, accepted, refused, modified, re-installed, updated… but rarely uninstalled.
So, how do we manage them ? Here is 3 systems I use:
1. Using your own gem repository.
It is really easier to maintain a ‘clean’ list of gems on your production servers if you only have one source, which is under your direct control. It is also a good incentive to do some QA, before putting new libraries into production. Here is an example deployement of a ‘home’ repository to distribute the tmm1-amqp gem:
fire0# mkdir -p /var/www/gems_repository/gems
fire0# cd !$
fire0# gem fetch tmm1-ampq -s http://gems.github.com
fire0# cd ..
fire0# gem generate_index
fire0# gem server &
Note: If a web server is installed (apache, nginx, …), create a new vhost and you won’t need the “gem server” command, since the repository communicate through standard http protocol. While you can add as many gems you want in /var/ww/gems_repostory/gems, don’t forget to run the “gem generate_index” (in /var/www/gems_repository) to keep your index up to date. You can also fetch specific gems version using the “-v” flag to the fetch command.
On your servers (or localhost if you have only one environment), adding your new gems repository as a permanent sources can be accomplished with this command:
air0# gem sources -a http://your_gems_server:8088
or you can install specific gems by mentioning the correct source :
air0# gem install tmm1-amqp -s http://your_gems_server:8088
2. Using “gem stale”
This is a new command I’ve discovered in the ‘gem help commands’ output. It give the last access date of every installed gems. This info is version specific… hence it shows dependencies on specifics, old version, gems or unused one. Try it:
fire0# gem stale
note: this command was added RubyGems >= 1.2.0, you might need to update to use it.
3. Using “gem outdate”
This command will dump a list of the gems for which you have available update (through your sources).