Last Updated: September 09, 2019
·
26.03K
· akalyaev

Cleanup RVM

Part 1. RVM

Do not be surprised if one day you'll see something like this:

$ du -hs ~/.rvm
1.2G    /home/vagrant/.rvm

To solve the problem run rvm cleanup all. It will remove stale source folders / archives and other miscellaneous data associated with rvm.

$ rvm cleanup all
Cleaning up rvm archives
Cleaning up rvm repos
Cleaning up rvm src
Cleaning up rvm log
Cleaning up rvm tmp
Cleaning up rvm gemsets
Cleaning up rvm links
Cleanup done.
$ du -hs ~/.rvm
307M    /home/vagrant/.rvm

Well, much better now!

Part 2. Gemset

To cleanup outdated gems run rvm gemset empty [gemset]. It will remove all the gems, so you will need to run bundle install after that.

$ rvm gemset list

gemsets for ruby-2.0.0-p353 (found in /home/vagrant/.rvm/gems/ruby-2.0.0-p353)
=> (default)
   global
$ rvm gemset empty default
Are you SURE you wish to remove the installed gems for gemset 'ruby-2.0.0-p353' (/home/vagrant/.rvm/gems/ruby-2.0.0-p353)?
(anything other than 'yes' will cancel) > yes

There is a tip to empty all the gemsets.

Part 3. Global gem cachedir

Run rvm gemset globalcache enable (thanks to @mpapis). It will enable global gem cachedir, which will be used to store gems (we do not want to store the same gem for each Ruby version, obviously)

$ rvm gemset globalcache enable
Enabling global cache for gems.
Moving the gem cache for ruby-2.0.0-p353 to the global cache.

3 Responses
Add your response

do not forget - rvm gemset globalcache enable

over 1 year ago ·

Cool tip.

I also like to use "rvm disk-usage all" for more details about rvm disk usage.

over 1 year ago ·

thanks :)

over 1 year ago ·