Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to make gem install command only install when not installed or update needed

Tags:

ruby

gem

i've read the documentation from rubygems site, but i guess the "gem install" command always reinstall, recompile everything, even if the same version already installed..

how to make gem install command only install when needed?

like image 711
Kokizzu Avatar asked Jan 24 '13 13:01

Kokizzu


2 Answers

It looks like the --conservative flag will make the gem command do what you want.

gem install rake --conservative

From the documentation gem install --help:

--conservative Don't attempt to upgrade gems already meeting version requirement

like image 165
georgehemmings Avatar answered Oct 01 '22 23:10

georgehemmings


You may want to use something external like gembundler to handle project’s gem installation.

If you must use rubygems directly for this, a command like

ruby -e "puts `gem install GEMTOINSTALL` if(`gem list --no-versions | grep GEMTOINSTALL`) == ''"

would do the job.

like image 38
Smar Avatar answered Oct 02 '22 01:10

Smar