Installing Rails 3 (beta 4) Using RVM

I’ve been collecting Rails 3 links ever since the first beta hit but I’ve been putting off installing it because I’ve been terribly busy and some of the early problems that I was reading on Twitter (namely with Bundler) turned me off.

Yesterday, I finally had enough time to start the installation and documentation process. For those following this guide, I should warn you in advance, Rails 3 is a fast moving target. Stuff is changing all the time, so by the time that you come across this guide it might be out of date or not The Rails Way of doing things.

I’ll try to keep it updated as best I can, but keep that warning in mind.

One more thing, the following should work with *nixes, but for those curious, I’m using OS X — Snow Leopard.

Note: Don’t prefix sudo when installing or uninstalling gems into an rvm’d environment.

Let’s get started by installing RVM first. There are many ways to install RVM, but I chose the gem method.

sudo gem install rvm

Once the gem has been installed run the install process.


This should install and configure it for your shell (it did for me), but if it doesn’t, refer to the RVM install documentation for setting up your shell correctly.

I found that the gem version was a version behind the head version, so I updated it using:

rvm update --head

Followed by:

rvm reload

From some of the links that I’ve been reading, it’s been suggested that you install Ruby 1.9.2 for use with Rails 3. Using RVM, this is easy to do:

rvm install 1.9.2-head

Installing and compiling Ruby 1.9.2 takes a while.

Switch over to the 1.9.2-head version and let’s setup a Rails 3 gemset:

rvm --create use 1.9.2-head@rails3

Install the pre-release of Rails 3:

gem install rails --pre

If everything has gone well we should be able to see beta 3 when running the rails —version command:

rails --version
Rails 3.0.0.beta4

Note: If you get a rails/cli error here it’s possible that you already have another beta version installed from somewhere. You can uninstall the previous beta gems, but it’s probably easier to just clean your gems instead:

gem clean

Note: This will only clean the gems in your rvm’d environment. It won’t affect any other Ruby/RubyGems install.

Since I use RSpec for my testing framework, I installed those gems:

gem install rspec --prerelease
gem install rspec-rails --prerelease

At this point, Rails should be installed and waiting for you to create a new project using:

rails new [path/project_name]

If you don’t specify a -d option to the rails command then it’ll use SQLite as the database, but you can always using the database of your choice:

rails new [path/project_name] -d mysql|postgres|sqlite3

Once you’ve created a project open it up in your editor of choice and familiarize yourself with the Gemfile file.

You should pay attention to the :require directive on gems. Sometimes the gem name and the library name aren’t the same. For example, here is the aws-s3 gem with its require line:

# gem 'aws-s3', :require => 'aws/s3'

If you want to install Rails Edge then comment out or delete the line from the Gemfile:

gem 'rails', '3.0.0.beta4'

And uncomment the line:

# gem 'rails', :git => 'git://github.com/rails/rails.git'

If you’re having weird issues with Rails 4, upgrading to Edge might be the way to go. I know that it fixes and error in a form bypassing validation in Rails3Beta2, so it might be worth it.

You should also note the database gem that’s listed in your Gemfile. In a simple project that I created it was listed as:

gem 'sqlite3-ruby', :require => 'sqlite3'

Since I installed RSpec and RSpec Rails, I should tell Bundler about them. Note that I’m only installing them in the test environment.

I added the following to the bottom of the Gemfile:

group :test do
  gem 'rspec', '>= 2.0.0.beta.12'
  gem 'rspec-rails', '>= 2.0.0.beta.12'

After you’ve edited your Gemfile to your liking, install them with Bundler:

bundle install

Once all of the gems have been installed, you should have a working Rails application that you can test by running:

rails server

If everything has gone according to plan you should have a working Rails3Beta4 app running.


Comments are closed

Comments are closed on this post. If you have something on your mind regarding this post, don't hesitate to drop me a line.