Ruby is a dynamic, open-source programming language behind Ruby on Rails framework. It is especially appealing to beginners because of its highly readable and clear syntax, allowing users to develop faster and more efficiently.

In this guide, find three options to install Ruby on Ubuntu 18.04 – either from the Ubuntu repository or from third-party tools (RVM or rbenv).

installation of ruby main image


  • Ubuntu 18.04 Bionic Beaver installed and running
  • A user with sudo privileges. To create a sudo user on Ubuntu, read this.
  • Access to a terminal/command line
  • The apt tool, pre-loaded in Ubuntu and other Debian-based distros.

Option 1: Install Ruby from the Ubuntu Repository

To install Ruby from the default Ubuntu repositories, follow these steps:

1. Open the terminal either by using Ctrl+Alt+T keyboard shortcut. Or,  by running a search in Ubuntu Dash and typing in the word terminal and selecting the Terminal Icon as seen in the image below.

Ubuntu repository terminal

2. Make sure to update the package repository cache to ensure you install the latest versions of the software.

To do so, type in the following command:

sudo apt update

3. Start the Ruby installation process by running the command:

sudo apt install ruby-full

Press y and hit Enter to verify the installation.

4. To check whether the installation was successful, type in the command:

ruby –v 

The output you receive will show you which version of Ruby you have installed, just like in the image below:

As you can see, we have installed Ruby version 2.5.1.

successful ruby installation

Option 2: Installing Ruby with RVM

Ruby Version Manager (RVM) is a command-line tool which allows you to easily install, manage and work with Ruby versions and their gems.

To enable RVM, you will have to install the GPG keys to verify the installation package.

Step 1: Install GPG

1. Start with running the command:

sudo apt install gnupg

2. Next, install the keys:

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

Step 2: Install RVM

1. Before installing RVM, you will need to install the software pre-requisites with the command:

sudo apt install software-properties-common

2. Next, you will add the PPA repository for Ubuntu and finally install RVM.

sudo apt-add-repository -y ppa:rael-gc/rvm
sudo apt update
sudo apt install rvm

3. At this point, it is recommended to restart your system.

Step 3: Install Ruby

Now that you have set up the RVM command-line, you can install Ruby by typing the following command:

rvm install 2.5.1

Make sure the installation was successful by checking the version of Ruby you have installed with the command:

ruby –v

Note: 2.5.1 is one version of Ruby. You can replace this number with the latest stable version of Ruby.

Option 3: Install Ruby Using rbenv

Simple Ruby Version Management (rbenv) is a third-party command tool designed for easier alternation between various Ruby versions. It is specific to switching Ruby versions, making it simple and predictable.

1. Copy the command below to install the packages and dependencies required to build Ruby:

sudo apt install git curl libssl-dev libreadline-dev zlib1g-dev autoconf bison build-essential libyaml-dev libreadline-dev libncurses5-dev libffi-dev libgdbm-dev

2. To install rbenv and ruby-build, type in the command:

curl -sL | bash -

3. Next, you need to add rbenv to your path with the following three (3) commands:

echo ‘export PATH=”$HOME/ .rbenv/bin:$PATH”’ >> ~/.bashrc
echo ‘eval “$(rbenv init –)”’ >> ~/.bashrc
source ~/.bashrc

4. After you have installed rbenv, you can install the latest version of Ruby. Run the command:

rbenv install 2.5.1

5. Make sure the installation was successful by checking the version of Ruby you have installed:

ruby –v 

Update Ruby Gems Package Manager

To install, manage and distribute your Ruby libraries (also called gems) you will need the package manager RubyGems.

Each gem contains a Ruby code which you can share with other users. Primarily, these gems serve as libraries from which you can easily install any package required.

The RubyGems management framework is part of Ruby which is why you don’t have to install it separately.

However, you may need to update to the latest version with the command:

gem update --system


By following one of the three methods above, you will successfully install Ruby on Ubuntu 18.04.

Next, you may want to install a full Ruby on Rails stack. This is one of the most popular application-development stacks in use. Rails is a development framework for the Ruby programming language that simplifies and speeds up app development.