How to Delete Ruby Gems, Part II

January 27, 2014

Back in June I wrote about how to delete Ruby gems and presented a solution that involved a short script. Recently I went through another round of cleaning up Gems and discovered and even shorter method for deleting them.

for i in `gem list --no-versions`; do gem uninstall -aIx $i; done

This will ignore all default Gems errors. Simple and direct.

The flags specified with the gem uninstall, -aIx mean the command will remove all matching versions (-a), will ignore dependency requirements (-I), and will remove executables without needing confirmation (-x). You can read more about gem uninsall on the RubyGems Guide.

Author's profile picture

Mark H. Nichols

I am a husband, cellist, code prole, nerd, technologist, and all around good guy living and working in fly-over country. You should follow me on Twitter.