Installing Ruby and Rails on Ubuntu and OSX with RVM

Oct 11, 2013 • val antonini

I've been wanting to try Ruby for a while and thought I'd share how to get up and running with Ruby and Ruby on Rails on Linux. 2 things that stood out to me when reading up about Ruby development were:

1. Develop on Linux or OSX if you can. This Stackoverflow post highlights some of the challenges of Ruby/Rails in Windows. I prefer to run Linux in a virtual machine but that's just my preference.

2. Install Ruby using RVM (Ruby Version Manager) instead of apt. More information about RVM can be found on the official RVM (Ruby Version Manager) website.

Install curl

sudo apt-get install curl

Install ruby and reload bash profile

curl -L https://get.rvm.io | bash -s stable --ruby
. ~/.bash_profile

Confirm Ruby is installed

ruby -v
You should see an output similar to below:
ruby 2.0.0p247 (2013-06-27 revision 41674) [x86_64-linux]

Turn off ri and rdoc generation

I like to turn off ri and rdoc generation when installing gems. You can do this by creating a .gemrc file in your home directory and adding the below:
install: --no-rdoc --no-ri
update: --no-rdoc --no-ri

Install Rails (this can take a while)

gem install rails

Create a test application and start it up

rails new test_app
cd test_app
rails server

If you get the below error:

"Could not find a JavaScript runtime. See https://github.com/sstephenson/execjs for a list of available runtimes. (ExecJS::RuntimeUnavailable)"

You will need a Javascript runtime, I use nodejs:

sudo apt-get install nodejs

If you received no error, you should be able to navigate to your application in a browser (http://0.0.0.0:3000/) and see the rails welcome page.