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 developm
When trying to remove gems installed as root, xargs seems to halt when it encounters an error trying to uninstall a default gem:
sudo gem list | cut -d" " -f1 | xargs gem uninstall -aIx
# ERROR: While executing gem ... (Gem::InstallError)
# gem "test-unit" cannot be uninstalled because it is a default gem
This won't work for everyone, but here's what I used instead:
sudo for gem (`gem list | cut -d" " -f1`); do gem uninstall $gem -aIx; done