Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cleanup old refs in Ruby Version Manager (RVM)

I need to free disk space on my local machine, which is almost allocated into my Ruby Version Manager (RVM) dir.

Now, it seems I got just one ruby version ( 1.9.2p136 ) :

lsoave@ubuntu:~/rails/github/gitwatcher$ ruby -v
ruby 1.9.2p136 (2010-12-25 revision 30365) [i686-linux]
lsoave@ubuntu:~/rails/github/gitwatcher$ 

lsoave@ubuntu:~/rails/github/gitwatcher$ rvm list
rvm rubies
=> ruby-1.9.2-p136 [ i386 ] 
lsoave@ubuntu:~/rails/github/gitwatcher$

lsoave@ubuntu:~/rails/github/gitwatcher$ which ruby
/home/lsoave/.rvm/rubies/ruby-1.9.2-p136/bin/ruby
lsoave@ubuntu:~/rails/github/gitwatcher$ 

but my RVM dir, have many others unrelated dirs/versions :

lsoave@ubuntu:~/rails/github/gitwatcher$ ls -la ~/.rvm/gems
total 72
drwxr-xr-x 18 lsoave lsoave 4096 2011-05-21 15:44 .
drwxr-xr-x 23 lsoave lsoave 4096 2011-02-10 22:46 ..
drwxr-xr-x  2 lsoave lsoave 4096 2010-08-29 19:50 cache
drwxr-xr-x  2 lsoave lsoave 4096 2010-08-31 21:50 jruby-1.3.7
drwxr-xr-x  2 lsoave lsoave 4096 2010-08-31 21:50 jruby-1.3.8
drwxr-xr-x  2 lsoave lsoave 4096 2011-05-21 15:44 ree-1.8.7-2010.02
drwxr-xr-x  8 lsoave lsoave 4096 2010-09-08 11:25 ruby-1.8.7-p302
drwxr-xr-x  7 lsoave lsoave 4096 2010-08-29 22:00 ruby-1.8.7-p302@global
drwxr-xr-x  7 lsoave lsoave 4096 2010-08-29 22:24 ruby-1.9.2-head
drwxr-xr-x  7 lsoave lsoave 4096 2010-08-29 22:24 ruby-1.9.2-head@global
drwxr-xr-x  8 lsoave lsoave 4096 2010-08-31 23:47 ruby-1.9.2-p0
drwxr-xr-x  7 lsoave lsoave 4096 2010-08-29 19:50 ruby-1.9.2-p0@global
drwxr-xr-x  8 lsoave lsoave 4096 2011-02-10 19:44 ruby-1.9.2-p136
drwxr-xr-x  7 lsoave lsoave 4096 2011-02-10 19:23 ruby-1.9.2-p136@global
drwxr-xr-x  7 lsoave lsoave 4096 2011-04-08 21:21 ruby-1.9.2-p136@greendog
drwxr-xr-x  7 lsoave lsoave 4096 2011-04-09 00:57 ruby-1.9.2-p136@greendog2
drwxr-xr-x  7 lsoave lsoave 4096 2011-02-15 00:09 ruby-1.9.2-p136@greendog99
drwxr-xr-x  2 lsoave lsoave 4096 2011-02-10 19:04 system
lsoave@ubuntu:~/rails/github/gitwatcher$

is it save to remove all dirs remaining with just "ruby-1.9.2-p136" and "ruby-1.9.2-p136@global" dirs (ruby-1.9.2-p136@greendog* are old and "rvm system" return nothing) ? Will I use "rm" command, or are there RVM embodied commands to cleanup a better way ? Is it possible cleanup the cache dir ?

Thanks in advance. luca

like image 460
Luca G. Soave Avatar asked Jun 02 '11 08:06

Luca G. Soave


2 Answers

I suppose rvm cleanup could do the trick.

Other than that I don't see any reason that deleting the actual gem directories inside RVM if they aren't associated with RVM any more.

If the matching entry doesn't exist in environments then it is safe to delete the accompanying gem dir. As nothing else points to it that RVM would be able to use.

like image 156
stuartc Avatar answered Nov 09 '22 09:11

stuartc


... it turn out that some of the previous, not used refs, were just gemsets:

rvm gemset list
lsoave@ubuntu:~$ rvm gemset list

gemsets for ruby-1.9.2-p136 (found in /home/lsoave/.rvm/gems/ruby-1.9.2-p136)
global
greendog
greendog2
greendog99

lsoave@ubuntu:~$

which I removed like following:

lsoave@ubuntu:~$ rvm gemset delete greendog99
Are you SURE you wish to remove the entire gemset directory 'greendog99' (/home/lsoave/.rvm/gems/ruby-1.9.2-p136@greendog99)?
(anything other than 'yes' will cancel) > yes
lsoave@ubuntu:~$ rvm gemset delete greendog2
Are you SURE you wish to remove the entire gemset directory 'greendog2' (/home/lsoave/.rvm/gems/ruby-1.9.2-p136@greendog2)?
(anything other than 'yes' will cancel) > yes
lsoave@ubuntu:~$ rvm gemset delete greendog
Are you SURE you wish to remove the entire gemset directory 'greendog' (/home/lsoave/.rvm/gems/ruby-1.9.2-p136@greendog)?
(anything other than 'yes' will cancel) > yes
lsoave@ubuntu:~$

than I made a backup of one of the old 'lib' ( just in case ... ):

lsoave@ubuntu:~/.rvm/gems$ tar zcvf ruby-1.8.7-p302.gz ./ruby-1.8.7-p302

and removed the relative directory as a previous comment talk, with stuartc:

lsoave@ubuntu:~/.rvm/gems$ rm -rf ./ruby-1.8.7-p302

now back to work.

I'll wait a couple of days, looking for everything is right ...

like image 27
Luca G. Soave Avatar answered Nov 09 '22 09:11

Luca G. Soave