Last Updated: February 25, 2016
·
5.394K
· kugaevsky

Cleanup outdated gems from all your rvm gemsets

There is no day without useful gem release.

And if you prefer staying on the edge and run bundle update command everyday, this small script can help you keep your gemsets free from old-versioned gems.

It runs across every gemset you have and executes gem cleanup command.

#!/bin/sh

echo "NB! This process could be too destructive sometimes and you may need to run 'bundle' command from your project directory."
echo "Do you want to cleanup all gemsets?"
read -p "(anything other than 'yes' will cancel) > " ANSWER

if [[ $ANSWER != "yes" ]]
  then
    echo "Phew...\nMay be another day."
  else
    for gemset in `ls $rvm_path/gems | grep @`
    do
      echo "Switching to gemset $gemset"
      rvm $gemset do gem cleanup
    done
    echo "\nAll gemsets are clean and shiny!"
fi

exit 0

Gist

1 Response
Add your response

awesome, thanks!!

over 1 year ago ·