59

I installed RVM with a few versions of Ruby-interpreters some time ago. How I can to update it, because new versions are already released?

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 the documentation.

the Tin Man
  • 158,662
  • 42
  • 215
  • 303
mystdeim
  • 4,802
  • 11
  • 49
  • 77

6 Answers6

85

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

nihique
  • 5,738
  • 2
  • 25
  • 27
  • what will happen to my gemsets of 1.9.2-preview1 – Anand Mar 16 '11 at 12:02
  • 2
    according to `rvm help upgrade`: `Will migrate gemsets, wrappers, aliases and environment files.` – asymmetric Apr 11 '11 at 12:44
  • Also, current versions of RVM upgrade in an expected order `rvm upgrade [source ruby] [destination ruby]`. Wayne fixed that :) – Abel Oct 03 '11 at 16:53
  • 1
    `rvm upgrade` is the recommended way, so this should be the accepted answer. – kynan Dec 24 '11 at 11:25
  • the screencast is a little outdated it would seem, now you run it as: `rvm upgrade from to` instead of the earlier to -> from. – lfxgroove Mar 26 '13 at 10:24
  • Also, if you just want to upgrade to the latest patch version, just using the major version works well: `rvm upgrade 1.9.3 1.9.3` – Adam Lindberg Jul 10 '13 at 15:52
25

[Edit: rvm has a new command to upgrade-- you likely want to use the answer by andy318]

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.

joelparkerhenderson
  • 34,808
  • 19
  • 98
  • 119
Konstantin Haase
  • 25,687
  • 2
  • 57
  • 59
21

Current rvm version provides an easier way to do this. The 'upgrade' option will migrate gem sets, wrappers and environment files -

$ rvm upgrade 1.9.2-p136 1.9.2-p180

To find out if there is a more recent stable version of a ruby implementation for you to upgrade to, first get the latest version of RVM and then enumerate the known versions of Ruby.

$ rvm get stable
$ rvm list known

You can compare this the ruby versions installed on your system

$ rvm list rubies
andy318
  • 542
  • 4
  • 8
3

you can install latest rvm and ruby by :

$ \curl -L https://get.rvm.io | bash -s stable --ruby

and check all the ruby version with stability

$ rvm list known

can also check details here : http://www.ruby-lang.org/en/downloads/

$ rvm install ruby 2.0.0-p247

Use when you want to download specific version or know this is stable.

Jigar Bhatt
  • 4,217
  • 2
  • 34
  • 42
2

There's a fantastic RVM GUI called JewelryBox that I use to manage my Ruby versions

http://jewelrybox.unfiniti.com

Adam Waite
  • 19,175
  • 22
  • 126
  • 148
  • After reading this I checked https://rvm.io/ and JewelryBox is stated to be the **official RVM GUI** (OS X users only). This was a real help, thank you. – cenk Jul 30 '13 at 12:08
-1

I think that is:

rvm all do gemset update
crsuarezf
  • 1,201
  • 3
  • 18
  • 33