Wednesday, February 16, 2011

Uninstall all the gems

Many time a rails developer have an situation where they want to uninstall all gems which are installed.
Here we can take an advantage of pipelining output from one command to other command.
gem clean
This command will remove multiple versions of gems and will keep only higher version of gem.
gem list --no-version | xargs gem uninstall
Here we are using pipelining, where command first will list all gems with no version, and second command will take it for consume.

Extra :

If you need to exclude some gem from being uninstall, use following command,
gem list --no-version | grep -v "rake" | xargs rvmsudo gem uninstall

No comments:

Post a Comment