views:

22

answers:

1

gem install XXX seems to run the installation process even if the package is already installed. i.e. if I do

$ gem install chef
...
$ gem list | grep chef
chef (0.9.8)
$ gem install chef
...

the second gem install chef seems to install chef again!

How can I get this to result in a noop and the message "chef is already installed", or similar, the way most package management tools work?

I can achieve what I want via

$ gem list | grep chef > /dev/null || gem install chef

but there must be a better way that I'm missing.

A: 

According to the /lib/rubygems/commands/install_command.rb file of the RubyGems sources, there is no other, "legal", way to do that, so your own is the best.

floatless