Allow a quick way to ensure correct installed/uninstalled/version state for a gem #269

Closed
donv opened this Issue Jan 29, 2012 · 4 comments

Projects

None yet

5 participants

@donv
Contributor
donv commented Jan 29, 2012

Hi!

I miss a way to ensure the installed/uninstalled/version state of a gem while changing as little as possible in the setup and still receive a return code of 0 from ruby gems.

gem install --no-reinstall [-v desired-version] <gem-name>

should install the gem if not installed, and do nothing if the gem is installed. In both cases a 0 should be received as a return code. Similarly

gem uninstall --ignore-missing [-v unwanted-version] <gem-name>

should uninstall the gem if it was installed and do nothing if it wasn't installed. In both cases it should return 0 as return code.

Actually, I wouldn't mind if this behavior was the default, and install would require a switch to re-install a gem.

Have a nice day!

@zenspider
Contributor

I don't know what this means or why you'd want it. Seems like gem query accomplishes all of this already:


4539 % gem query -i -n rake -v 0.9.2.2
true
4540 % echo $?
0
4541 % gem query -i -n rake -v 0.9.2.3
false
4542 % echo $?
1
@donv
Contributor
donv commented Jan 30, 2012

Thank you for your comment.

gem querydoes only half the job. It does not ensure that the state of the gem is as ordered.

On a unix system, I do have the option to chain gem querywith gem install, but it would be more convenient if the gem command could do it in one go. On windows, I am not sure how I would do this:

sudo gem query -q -i -n rake -v 0.9.2.2 || sudo gem install rake -v 0.9.2.2

sudo gem query -q --no-installed -n rake -v 0.9.2 || sudo gem uninstall rake -v 0.9.2

Why I want a way to do this in one operation? It is more convenient and offers a platform independent way of ensuring the state of a gem in an efficient way.

I would also like this operation to be quiet. The examples above have undesired output. Yes, I can redirect the output to /dev/null on unix, making the example even more complex.

The example above also does not distinguish between the situation where the gem is not installed, and when there is something else wrong. If the gem is not installed, I would like to install it. If there is something wrong (like a network problem), I do not want to try to install the gem.

RubyGems does have all the information, and could easily implement a check-and-execute of install/uninstall/update. It would also be noticably more efficient on JRuby since it would only fire one Ruby process to get the job done.

yum, apt-get, and other packaging systems offer this feature, and I do miss it in RubyGems.

Please consider it.

@evanphx evanphx was assigned Mar 9, 2012
@evanphx
Member
evanphx commented Oct 7, 2012

in the case of gem install --no-reinstall blah would it return right away if any version of the gem blah is available?

@drbrain
Member
drbrain commented Nov 28, 2012

Closing due to no feedback in 2 months. Please reopen if you have additional feedback.

@drbrain drbrain closed this Nov 28, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment