How To Install Ruby on Rails on Ubuntu 14.04 using RVM

Published on April 22, 2014
How To Install Ruby on Rails on Ubuntu 14.04 using RVM
Not using Ubuntu 14.04?Choose a different version or distribution.
Ubuntu 14.04


Ruby on Rails is one of the most popular application stacks for developers wishing to create sites and web apps. The Ruby programming language, coupled with the Rails development framework, makes app development simple.

Since Ruby on Rails doesn’t come in a neatly packaged format, getting the framework installed used to be one of the more difficult parts of getting started. Luckily, tools like rvm, the Ruby Version Manager, have made installation simple.

In this guide, we’ll show how to install rvm on an Ubuntu 14.04 VPS, and use it to install a stable version of Ruby and Rails. Although you can go through these procedures as the root user, we’ll assume you’re operating using an unprivileged user as shown in steps 1-4 in this guide.

The Quick Way

The quickest way of installing Ruby on Rails with rvm is to run the following commands as a regular user:

gpg --keyserver hkp://keys.gnupg.net --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3
\curl -sSL https://get.rvm.io | bash -s stable --rails

You will be prompted for your regular user’s password as part of the installation procedure.

Let’s go over exactly what’s happening here.

The gpg command contacts a public key server and requests a key associated with the given ID. In this case we are requesting the RVM project’s key which is used to sign each RVM release. Having the RVM project’s public key allows us to verify the legitimacy of the RVM release we will be downloading, which is signed with the matching private key.

The \curl portion uses the curl web grabbing utility to grab a script file from the rvm website. The backslash that leads the command ensures that we are using the regular curl command and not any altered, aliased version.

The -s flag indicates that the utility should operate in silent mode, the -S flag overrides some of this to allow curl to output errors if it fails. The -L flag tells the utility to follow redirects.

The script is then piped directly to bash for processing. The -s flag indicates that the input is coming from standard in. We then specify that we want the latest stable version of rvm, and that we also want to install the latest stable Rails version, which will pull in the associated Ruby.

Following a long installation procedure, all you need to do is source the rvm scripts by typing:

source ~/.rvm/scripts/rvm

You should now have a full Ruby on Rails environment configured.

Installing Specific Ruby and Rails Versions

If you need to install specific versions of Ruby for your application, you can do so with rvm like this:

<pre> rvm install <span class=“highlight”>ruby_version</span> </pre>

After the installation, we can list the available Ruby versions we have installed by typing:

rvm list

We can switch between the Ruby versions by typing:

<pre> rvm use <span class=“highlight”>ruby_version</span> </pre>

We can use various Rails versions with each Ruby by creating gemsets and then installing Rails within those using the normal gem commands:

<pre> rvm gemset create <span class=“highlight”>gemset_name</span> # create a gemset rvm <span class=“highlight”>ruby_version</span>@<span class=“highlight”>gemset_name</span> # specify Ruby version and our new gemset gem install rails -v <span class=“highlight”>rails_version</span> # install specific Rails version </pre>

The gemsets allow us to have self-contained environments for gems and allow us to have multiple environments for each version of Ruby that we install.

Learning More

We have covered the basics of how to install rvm and Ruby on Rails here, but there is a lot more to learn about rvm. Check out our article on how to use rvm to manage your Ruby environments to learn more about working with rvm.

<div class=“author”>By Justin Ellingwood</div>

Thanks for learning with the DigitalOcean Community. Check out our offerings for compute, storage, networking, and managed databases.

Learn more about our products

About the authors

Still looking for an answer?

Ask a questionSearch for more help

Was this helpful?

This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Thanks works well, but now what? I want to deploy with Capistrano but I cannot figure out how to do it. There is a tutorial though it uses rbenv. Can someone tell me where to find how to deploy with Capistrano and .rvm?

I had to add the key

gpg --keyserver hkp://keys.gnupg.net --recv-keys D39DC0E3

before step 1, as this was a fresh install.

I guess it would be a good idea to include the command to source the rvm scripts in .bashrc

echo “source ~/.rvm/scripts/rvm” >> ~/.bashrc

Thank you very much guys, you save my life! Awesome post, and Pura Vida from Costa Rica :)

Here is some more commands you need to include RVM Installation tutorial

Need to import key for the curl to work:

gpg --keyserver hkp://keys.gnupg.net --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3

Source : https://rvm.io/

hello bro…i have got an error while installing ruby…when i execute the following code \curl -sSL https://get.rvm.io | bash -s stable --rails it give me following error
Successfully installed rails-deprecated_sanitizer-1.0.3 ERROR: While executing gem … (Gem::RemoteFetcher::FetchError) bad response Service Unavailable 503 (https://rubygems.global.ssl.fastly.net/quick/Marshal.4.8/mini_portile-0.6.2.gemspec.rz)

please help me what i do

I’ve created a PPA (.deb package + auto updater) for rvm on 14.04.

Install instructions: https://github.com/raelgc/ubuntu_rvm

Great post, thank you!

By the way, I could not find the file “~/.rvm/scripts/rvm”, hence “source ~/.rvm/scripts/rvm” did not work… You need to run “source /usr/local/rvm/scripts/rvm” instead. -tested in Ubuntu 14.04 LTS-


Worked great adding that to the bashrc as dennyac said, you should add it to article. thanks

Try DigitalOcean for free

Click below to sign up and get $200 of credit to try our products over 60 days!

Sign up

Join the Tech Talk
Success! Thank you! Please check your email for further details.

Please complete your information!

Featured on Community

Get our biweekly newsletter

Sign up for Infrastructure as a Newsletter.

Hollie's Hub for Good

Working on improving health and education, reducing inequality, and spurring economic growth? We'd like to help.

Become a contributor

Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.

Welcome to the developer cloud

DigitalOcean makes it simple to launch in the cloud and scale up as you grow — whether you're running one virtual machine or ten thousand.

Learn more
DigitalOcean Cloud Control Panel