Clear Installed Gems From your RVM Gemset

A word or two about RVM

When developing in a Ruby project I like to keep things nice and tidy by using the amazing Ruby Version Manager aka RVM. RVM allows me to easily switch between versions of Ruby as well as allowing me to create project-specific sets of installed gems that only apply to the project I want. It’s a great tool and you should check it out if you haven’t already.

Image courtesy of "Glitz UK":http://www.flickr.com/photos/glitzuk/4273785523/ Image courtesy of Glitz UK

Gem Clutter in Your Gemset?

There are occasions when you might let your gemset get a bit cluttered with gems that you don’t need or want any more. The temptation might be to delete and recreate your gemset from scratch when all you really want to do is empty your gemset of installed gems. This might be particularly useful if you want to clear out a load of dependencies that were installed by gems you no longer want.

At the command prompt, signified by the $ character below, make sure you’re using the gemset you want to empty (you might already be doing so if you’re using an .rvmrc file in your project).

$ rvm gemset use name_of_gemset

Once you’re using the correct gemset you can clear out the gems which have been installed by using

$ rvm gemset empty

This will leave your gemset completely intact while clearing out all installed gems, leaving you primed to reinstall the gems you require or run the bundle install process depending on your current circumstances.