June 10, 2013
For my day job I’ve been doing a lot of work with Chef, Vagrant, and veewee. All of these tools are continually evolving and, over the course of several weeks time, I’ve updated versions more than once. As a result my set of Ruby Gems was causing some conflicts trying to run
vagrant up after using veewee.
To clear things up so that I could make better use of RVM Gemsets to manage what Gems were loaded for a given process, I wanted to delete all Gems installed on my machine. A quick StackOverflow search lead me to this command:
$ [sudo] gem list --no-version | xargs [sudo] gem uninstall -aIx
While I’ve marked
sudo as optional, you should use them as a pair — either have both of them in the command or neither of them.
Running this command didn’t work as expected as it ran afoul of the default gems that are pre-installed with Ruby. Another search lead me to this gem-reset Gist on GitHub.
This script removes all Gems except the ones marked as default. I forked it and used the
wget option to run it. Once the script completed my machine only had the default gems installed.
For each of my Ruby-based projects I added a
.ruby-version file specifying the gemset name I wanted and the Ruby version desired. Next I visited each project, checked that the gemset was in use, and ran
bundle install to re-install the gems, this time in managed gemsets.
This not only cleared up the gem conflict I had introduced, but has made seeing and managing my installed Gems easier.