I had to clean my ruby gems because it was using a lot of space. So what were my options to get free space ? One single command to rule them all !
Here is a Windows command to uninstall all gems from your computer except a few one you cannot delete.
ruby -e "`gem list`.split(/$/).each { |line| puts `gem uninstall -Iax #{line.split(' ')[0]}` unless line.empty? }"
On Linux, to remove ALL gems, that would be:
gem list | cut -d" " -f1 | xargs gem uninstall -aIx
If you just want to clean your gem list and only keep the latest version of each gem, you can use this command
gem cleanup OR gem clean
After your system is clean, you can chose to add one gem after another with the “gem install <mygemname>” command or use the “bundle install” in a rails app.
Don’t forget to install bundler before using the bundler installer !
gem install bundler