tags:

views:

343

answers:

2

I installed RVM with a few version of ruby-interpreters some time ago. How I can to update it, because new versions are already realeased? I found only one way: rvm install 1.9.2-rc1 && rvm remove 1.9.2-preview1, but my gems are lost... Can I update branches time to time? I haven`t found any tips in documentation.

+7  A: 

AFAIK, there is no automatic way to do this at the moment, but something like this enables you to keep your gems:

 rvm use 1.9.2-preview1
 rvm gemset export
 rvm install 1.9.2-rc1
 rvm use 1.9.2-rc1
 rvm gemset import
 rvm remove 1.9.2-preview1

Now, for automating updates, you would have to detect version changes, that is easy, as you can simply use the return value of rvm use 1.9.2. Finding out what the new version is (1.9.2-rc1) is unnecessary, as it is aliased as 1.9.2. The trick is to find the latest installed version of 1.9.2. You could do something like this in a cron job:

# make sure you source rvm first
rvm update --head
rvm reload
if [ ! rvm use 1.9.2 ]; then
  for ruby_version in `rvm list strings`; do
    # find the latest version of 1.9.2
    case $ruby_version in
      ruby-1.9.2-*) latest192=$ruby_version;;
    esac
  done
  rvm use $latest192
  rvm gemset export 192.gems
  rvm install 1.9.2
  rvm use 1.9.2
  rvm gemset import 192
  rvm remove $latest192
fi

Did not try that, but I have similar code in my update script. I also slipped in a gem update and other stuff.

Feel free to visit the #rvm IRC channel on Freenode.

Konstantin Haase
+2  A: 

Use the rvm upgrade 1.9.2-preview1 1.9.2-rc1 command or watch this screencast

nihique