Ruby – Uninstall all installed gems, in OSX

rubyrubygems

There are instances where I would like to revert and uninstall all previous gem installations.

For instance, I needed to assist a friend migrate their rails development machine to use RVM. As they had been previously using the system-wide gem, he was experiencing many headaches when working with multiple projects. Essentially, he was the poster-child for an RVM convert.

How can I elegantly uninstall all of the gems on his OSX system?

Best Answer

Rubygems >= 2.1.0

gem uninstall -aIx

a removes all versions
I ignores dependencies
x includes executables

Rubgems < 2.1.0

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