Ruby is an open-source, object-oriented, and general-purpose programming language that has recently surged in popularity as the de-facto tool for building web applications.
You are probably already familiar with Ruby. Even those who have nothing to do with software have, at some point, heard of this programming language. And that should come as no surprise; Ruby is an incredibly robust language with relatively comprehendible sentence structure. Ruby is used in many tech industries. Perhaps the greatest impact of Ruby is the ‘Ruby on Rails’ framework, upon which many famous websites are built, such as twitter.com, airbnb.com, groupon.com, and github.com.
This article will demonstrate two different ways to get Ruby up and running on your system.
- Using Ubuntu’s official repositories
- Using Ruby Environmental Manager, or RVM
Method 1: From Ubuntu’s Official Repositories
To install Ruby on Ubuntu, our recommendation to download it from the standard Ubuntu repositories, as this is relatively simpler than any other method. This method uses the apt package manager.
Step 1: Update the Package Index
Start by updating the package index. To do so, enter the command below:
Step 2: Install Ruby
Enter the following command to install Ruby:
$ sudo apt install ruby–full
The above command should install Ruby on your system. All that is left now is to check if the latest version was downloaded.
Step 3: Verify the Install
Sometimes, the most stable version is not installed. To make sure that this is not the case, type in the following command:
This will print the version of Ruby you installed in Step 2. The latest version, as of uploading this tutorial, is v2.7. 1, which could be updated again by the time you install Ruby on your system.
With your install verified, you can finally start using Ruby. If the version was not up-to-date, try the second method.
Method 2: Installing with Ruby Environmental Manager (RVM)
This method involves a command-line tool called Ruby Environmental Manager, or RVM. Using this tool would be preferable if you are working on several Ruby environments at once, as this allows you to manage Ruby on any Linux system.
Step 1: Install Related Dependencies
First, install the related dependencies. Use the following commands to do so:
$ sudo apt install curl g gcc autoconf automake bison libc6–dev
libffi–dev libgdbm–dev libncurses5–dev libsqlite3–dev libtool
libyaml–dev make pkg–config sqlite3 zlib1g–dev libgmp–dev
Step 2: Install Ruby Environment Manager
To install RVM, you will need to add the GPG key first. Enter the following command to do so:
$ gpg —keyserver hkp://keys.gnupg.net —recv–keys
Then, install RVM by entering the following:
$ curl –sSL https://get.rvm.io | bash –s stable
Step 3: Check for Latest Ruby Version
Enter the following to open the script environment variables and summon a list of Ruby versions compatible with your system:
$ source ~/.rvm/scripts/rvm
Step 4: Install Ruby
Now, you just need to pick a version to install. You should install the latest version available. Enter the following command to install Ruby:
To set this version of Ruby as the default version, type:
If you do not wish to install the latest version, then you must specify which version you would like to install.
For example, if you are downloading version 2.2.7, then you must modify the command as follows:
$ rvm install ruby–2.2.7
$ rvm —default use ruby–2.2.7
You have now successfully installed Ruby on your Ubuntu 20.04 system.
To print out the version number, type in the following:
This should verify the version installed on your system.
Ruby is a great language that balances the key components of functional and imperative programming, making it an incredibly versatile programming tool and a great place to start learning how to code.
This article discussed two methods to install Ruby. Downloading and installing Ruby directly from the Ubuntu repositories is the simplest and quickest way to go. However, using RVM comes with the additional benefit of managing the different versions to install and update.
About the author
I am a freelancing software project developer, a software engineering graduate and a content writer. I love working with Linux and open-source software.