Installing Rails 3.0 Beta 3 on Ubuntu Using RVM
After struggling for sometime I finally got Rails 3.0 beta 3 to work on Ubuntu. Instead of creating a virtual machine I gave RVM a try — and now I love RVM. I thought I’d best dump what worked for me in here.
If you don’t know what RVM is then read what Ruby Inside has to say about it. However for installation instructions I recommend the official installation guide. What follows is how to prepare RVM to compile Ruby with openssl and readline, install Ruby 1.9.2-head and finally install Rails 3.0 beta 3. I will try my best to keep it as short as possible.
Initial set up
I use Ubuntu 9.10 64-bit edition and assume that you are using a relatively new release of Ubuntu if not 9.10. You will also need RVM installed.
Let’s install some dependencies which will be required to compile Ruby. After that we install the openssl package for RVM. We need this package to compile Ruby with openssl because Rails will not start without it. Similarly we install the readline package without which the Rails console will not work.
# Dependencies for compiling Ruby $ sudo apt-get install curl bison build-essential autoconf zlib1g-dev libssl-dev libxml2-dev libreadline6-dev git-core subversion # openssl package for RVM $ rvm package install openssl # readline package for RVM $ rvm package install readline
I wanted to try Ruby 1.9.x so I didn’t try older patchlevels of 1.8.7, but the latest patchlevels of Ruby 1.8.7 have marshalling bugs that crash Rails. Ruby 1.9.1 segfaults for Rails 3.0 beta 3. I also tried Ruby 1.9.2-preview1 which gives problems with timezone, although I believe this is fixed in the Rails repository. What did work was Ruby 1.9.2-head and it is also recommended in the release notes of the second beta release of Rails 3.0. Note that the problems with Ruby 1.8.7 and Ruby 1.9.1 could be fixed before you read this article. Moving on let’s install Ruby with openssl and readline using RVM. Note that there is no space after the comma.
$ rvm install 1.9.2-head -C --with-openssl-dir=$rvm_path/usr,--with-readline-dir=$rvm_path/usr
This will get the latest source code from the SVN repository, configure it and then compile the source code. It will also install a few gems and set up all the paths. However RVM will not switch into this Ruby. After installation you will still be with your system Ruby.
Once the installation process is complete run the following commands to confirm that the installation was successful and finally switch to Ruby 1.9.2-head. Note that I have provided the output from my console as a sample. It will most likely be different for you.
$ rvm list => rvm Rubies ruby-1.9.2-head [ x86_64 ] System Ruby system [ ] $ ruby -v => ruby 1.8.7 (2009-06-12 patchlevel 174) [x86_64-linux] $ rvm use 1.9.2-head => Using ruby 1.9.2 head $ ruby -v => ruby 1.9.2dev (2010-04-17 trunk 27376) [x86_64-linux]
Install Rails 3.0 beta 3
Installing Rails is now very easy. Note that sudo is not used to install the gems. If you use sudo the gems will be installed in the system directories. We don’t want that because RVM maintains the Rubies and gems inside the home directory of the user.
$ gem install sqlite3-ruby $ gem install rails --pre
If you want to use MySQL or some other database then install the necessary gems. That is it! You should have a working Rails 3.0 install now. Remember that every time you open a new terminal you will need to switch to Ruby 1.9.2-head. You can also set this as the default Ruby to be used. Have fun playing around with Rails 3.0 beta 3!