I am working on an Octopress blog, so I set up a separate gemset and did rvm use gemset octopress
. It all worked fine. However, I opened a new ZSH tab (I'm on OS X Mountain Lion, if that's relevant) and it fell back to the previous gemset I was using. I didn't know that at that point though, so I ran bundle install
. I noticed that it installed all the gems I had already installed in the Octopress gemset, so I figured out what was happening. The question: is there an easy way to undo this bundle install
, so that I don't have all these gems in the other gemset, or should I uninstall them manually gem by gem (they are quite a few). Thanks.
Asked
Active
Viewed 4,470 times
2

Alexander Popov
- 23,073
- 19
- 91
- 130
-
If you want to use specific versions of Gems just state them in the gem file and the run bundle update. If there are gems included that you don't want or need just gem uninstall Gem_name – Mini John Aug 30 '13 at 20:47
-
1You correctly answered your own question. I like to copy/paste the output of bundle install to a text file for reference before I start uninstalling any gems. – Teddy Aug 30 '13 at 20:50
2 Answers
3
you can empty gemsets with rvm:
rvm gemset empty
it will remove all gems from the selected gemset, you can also switch temporarly to other gemset with:
rvm @the-other-gemset do rvm gemset empty

mpapis
- 52,729
- 14
- 121
- 158
-
Nice, thank you :) So the idea is that I empty the relevant gemset and then from within the correct application folder I run bundle install to only populate it with the gems needed for that particular application, right? – Alexander Popov Aug 30 '13 at 23:13
2
A couple of days ago I had this same problem (once again) and solved it by writing this command:
$ threshold="20m"; dir="`rvm gemdir`/gems"; find -X "$dir" -type d -maxdepth 1 -mindepth 1 -mtime -"$threshold" | xargs basename | sed -e 's/-\(\([0-9]\{1,\}.\)*[0-9]\{1,\}\)$/ \1/g' -e 's/\(.*\) \(.*\)/gem uninstall \1 --version \2 --executables --ignore-dependencies \&/g'
It generates as many command lines as needed for uninstalling each gem which was added after the given threshold (above is twenty minutes). Then you just copy-and-paste those lines at a command prompt.
Before executing my command:
- make sure the current gemset is the one which is messed up
- set the
threshold
to a value that suits your needs
For example, the above command could generate the following lines:
gem uninstall elasticsearch --version 1.0.1 --executables --ignore-dependencies &
gem uninstall elasticsearch-api --version 1.0.1 --executables --ignore-dependencies &
gem uninstall elasticsearch-extensions --version 0.0.14 --executables --ignore-dependencies &
gem uninstall elasticsearch-transport --version 1.0.1 --executables --ignore-dependencies &
If you want some additional info, I posted an article here: http://noteslog.com/post/how-to-undo-a-wrong-bundle-install/

aercolino
- 2,193
- 1
- 22
- 20