How To Set up Ruby on Rails on Ubuntu 20.04

In this guide, we want to teach you How To Set up Ruby on Rails on Ubuntu 20.04.

Ruby on Rails (sometimes RoR) is the most popular open-source web application framework. It’s built with the Ruby programming language.

You can use Rails to help you build applications, from simple to complex, there are no limits to what you can accomplish with Rails!

How To Set up Ruby on Rails on Ubuntu 20.04

To complete this guide, you must log in to your server as a non-root user with sudo privileges. To do this, you can follow our guide the Initial Server Setup with Ubuntu 20.04.

In this tutorial, you will learn to install Ruby on Rails with RVM.

RVM, or Ruby Version Manager, is a command line tool that lets you manage and work with multiple Ruby development environments and allows you to switch between them.

Install RVM and Rails on Ubuntu 20.04

First, you need to update your local package index with the following command:

sudo apt update

Then, you need to install or update GPG to the most recent version in order to contact a public key server and request a key associated with the given ID:

sudo apt install gnupg2

Next, you must request the RVM project’s public key to verify the legitimacy of your download with the following command:

gpg2 --keyserver hkp:// --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3 7D2BAF1CF37B13E2069D6956105BD0E739499BDB

Now use the following command to download the RVM script installer and write it to a file named

\curl -sSL -o

When your download is completed, you can pipe it to bash to install the latest stable Rails version which will also pull in the associated latest stable release of Ruby by running the below command:

cat | bash -s stable --rails

When your download is completed, you will get the following command:

35 gems installed

* To start using RVM you need to run `source /usr/local/rvm/scripts/rvm`
in all your open shell windows, in rare cases you need to reopen all shell windows.

* To start using rails you need to run `rails new <project_dir>`.

Next, source the RVM scripts with the following command:

source /usr/local/rvm/scripts/rvm

Install a Specific version of Ruby on Rails on Ubuntu 20.04

To install a specific version of ruby, you can use the RVM. First, check to see which versions of Ruby are available by listing them:

rvm list known

You will get the following output:

# MRI Rubies
[ruby-]1.8.7[-head] # security released on head


Then, install the specific version of Ruby that you need through RVM, replacing the highlighted version number with your version of choice, such as ruby-3.0.0 or just 3.0.0:

rvm install 3.0.0
Already installed ruby-3.0.0.
To reinstall use:

rvm reinstall ruby-3.0.0

You can list available Ruby versions you have installed by typing:

rvm list
=* ruby-3.0.0 [ x86_64 ]

# => - current
# =* - current && default
# * - default

Since Rails is a gem, which is a standardized format that contains Ruby programs, you can also install various versions of Rails by using the gem command.

List the valid versions of Rails with the following command on Ubuntu 20.04:

gem search '^rails$' --all

rails (, 7.0.3,,,,, 7.0.2, 7.0.1, 7.0.0,, 6.1.6,, 6.1.5,,...

Next, you can install your required version of Rails. Replace the highlighted version number with your version of choice, such as

gem install rails -v
Successfully installed rails-
Parsing documentation for rails-
Done installing documentation for rails after 0 seconds
1 gem installed

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

To create a gemset you will use:

rvm gemset create gemset_name
ruby-3.0.0 - #gemset created /usr/local/rvm/gems/ruby-3.0.0@gemset_orca
ruby-3.0.0 - #generating gemset_orca wrappers........

To specify a Ruby version to use when creating a gemset, use:

rvm 3.0.0@gemset_name --create
Using /usr/local/rvm/gems/ruby-3.0.0 with gemset gemset_orca

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

For more information, you can visit the Ruby on Rails Guides page.


At this point, you learn to Set up Ruby on Rails with RVM on Ubuntu 20.04.

Hope you enjoy using it.

You may be interested in these articles:

Install and Configure Lighttpd on Ubuntu 20.04

Install Symfony PHP Framework on Ubuntu 20.04

Newsletter Updates

Enter your email address below and subscribe to our newsletter

Stay informed and not overwhelmed, subscribe now!