Andy Hawthorne
I write and I code.
How to Install or Upgrade RVM and Ruby
RVM is great for managing Ruby because OS X still has Ruby version 1.8.7 as the default. It occurred to me that I would still want to be able to update the Rubies I have installed via RVM. So after some research, I worked out a sequence that seems to work. We can also upgrade RVM itself at the same time.
I’m not normally of nervous disposition, and I only have good things to say about RVM. honestly. It’s superb, and it really does take (most) of the pain out of managing Ruby.
However, I have had some bad experiences with trying to get various things set up for the Ruby/Rails ecosystem. So I approached this task with some caution.
I could just pop along to the RVM web site and follow the instructions there. Then this article wouldn’t be necessary. But does it work on Mac OS X Lion? What about Ubuntu? Will it work as described there? Are there problems that need to be worked around? With those questions in mind, I went through the process to see what would happen.
I tested this process on:
- Mac OS X 10.6.8
- Mac OS X 10.7.2
- Ubuntu 11.10
Updating RVM
To update RVM itself, all you need to do in terminal/console is type:rvm get latestYou’ll see the process run through a couple of steps, and then complete with a nice message from RVM creator Wayne Seguin. It works with the same outcome on all 3 systems that I tested it on. Great, that’s one step out of the way, and completely painless.
Set Ruby version 1.9.3 as the default Ruby
On the 3 machines I tried this on, Ruby 1.9.2p290 was the default. I wanted to upgrade to 1.9.3p0, the latest stable version of Ruby. And I didn’t want any pain with broken gems, or missing references, or any of that stuff. In my (limited) experience, when those kind of errors happen, it isn’t usually RVM that is at fault. There will have been something odd happening between the OS and different gems needing different things, and so on. Then there is the user of course… Anyway, to upgrade the default Ruby you begin by typing the following in terminal:rvm upgrade 1.9.2-p290 1.9.3-p0the first part is the Ruby you want to upgrade from, the second part is the Ruby you want to upgrade to. it has to be in that order, right? You’ve been told, it won’t work any other way. Then things will get busy in the terminal window for a while. You’ll see the new Ruby being downloaded, then it will be extracted, configured, and compiled. this step takes a while. next, you will see that the old rubygems will be removed, and a new version of ruby gems gets installed. You will be asked a question shortly. it will be about moving gems from Ruby 1.9.2 to 1.9.3. I assumed that is what I needed, so I answered ‘yes’. You will also be asked about aliases and wrappers. At that stage I started to feel like a famous yellow cartoon character answering ‘Yes’ to everything. But it works.The process completes without reporting any errors – on OS X Lion.
What about Snow Leopard?
Everything worked in the same way as Lion, apart from when the gem set was being moved/created. Then I got an error message that looked like this: ERROR: Error running ‘ ‘ under , I was told to look in the log to be found at /Users/me/.rvm/log/gemset.pristine.log , which I did. There didn’t seem to be anything in it to be alarmed about, so I carried on. I got the message again while the new gem set was being created. But there was still nothing untoward in the log, so I carried on. The process then completed successfully. I’m not sure what the error meant, and it doesn’t seem to have caused any problems.What about Ubuntu?
I have already installed Ruby 1.9.3 from source and written about it here. Last time I tried to get RVM installed on a Ubuntu box, I failed miserably. I think that was down to the fact that I tried to install it through Apt. This time, what I did was much the same as you would do to install it on a Mac, with a few Linux related variations:- Make sure you have Git installed via the terminal:
sudo apt-get install git
- Make sure you have curl installed:
sudo apt-get install curl
- Then install RVM with the following command:
bash < <(curl -s https://rvm.beginrescueend.com/install/rvm)
- Use gedit or your favourite editor, to make sure that the .bashrc file has the reference to RVM in it. The reference looks like this: [[ -s "$HOME/.rvm/scripts/rvm" ]] && source “$HOME/.rvm/scripts/rvm” # Load RVM into a shell session *as a function* If it’s not there, paste it in. I’ve done this several times, and it is always there. But just in case…
- Then you can close the console and re-open it to pick up the changes.
- Now you can test that the changes have worked by issuing the following command on the terminal:
type rvm | head -1
It should back with “RVM is a function”, meaning you are finished, RVM is now installed.
Installing Ruby via RVM
So now we can install the latest version of Ruby. First though, it would be a good idea to make sure that we have all the required dependancies installed. Back on the terminal type:rvm requirementsThat will produce a list of dependencies for Ubuntu. So we can go ahead and install those:
sudo apt-get install build-essential openssl libreadline6 libreadline6-dev zlib1g zlib1g-dev libssl-dev libyaml-dev libsqlite3-0 libsqlite3-dev sqlite3 libxml2-dev libxslt-dev autoconf libc6-dev ncurses-dev automake libtool bison subversionFinally, we can install Ruby:
rvm install 1.9.3This will take a while, but it does complete without errors on a clean install of Ubuntu 11.10. A final step is to tell RVM which Ruby to use:
rvm use 1.9.3
Final Words
So I have covered upgrading Ruby versions that are installed via RVM, for both Snow Leopard and Lion. You have also learnt a way to successfully install RVM on Ubuntu 11.10. Feel free to share your experiences by commenting below. If you enjoyed this article, please consider subscribing.Tags: installing, Ruby, RVM, Ubuntu, upgrading
