Some time you may need to uninstall all the installed Ruby gems. Uninstalling individual gems is tedious job. Here you will find how to uninstall all the installed Ruby gems using single command.
First, we need a list of installed gems. Its easier to get list of installed gems by using the command:
gem list --no-version
The command to uninstall all the matching version of gems without any confirmation of dependencies and executables is:
gem uninstall -aIx GEM_NAME
Now, we use xargs command to uninstall all the installed gems:
gem list --no-version | xargs gem uninstall -aIx
If your system requires sudo privilege to uninstall gems use:
gem list –no-version | sudo xargs gem uninstall -aIxM
Awesome..
ReplyDeleteThis is broken in 2.0.0, Here is a script I wrote that should work for any version.
ReplyDeletehttps://gist.github.com/nathan/5042764
Or:
ReplyDeletesudo gem list --no-version | xargs sudo gem uninstall -aIx