Programming

Easy to Install Ruby with RVM on Ubuntu 20.04

In this tutorial, we shall see how it is easy to install Ruby with RVM on Ubuntu 20.04. We shall also see how to manage and uninstall RVM.

Ruby is an interpreted, high-level, general-purpose programming language. RVM manages multiple Ruby environments and allows you to switch between them.

Prerequisites

Let’s start with the installation.

1. Keep your server up to date

Always keep your server up to date for security updates.

# apt update -y

# apt- upgrade -y

2. Install RVM

First, import RVM signing key.

Import the RVM code-signing keys. The command below is an example, please verify the keys at https://rvm.io/rvm/security.

# gpg –keyserver hkp://pool.sks-keyservers.net –recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3 7D2BAF1CF37B13E2069D6956105BD0E739499BDB

Now, download and install RVM.

Go to the /tmp directory

# cd /tmp

Download a stable version of the RVM script.

# apt-get update && curl -sSL https://get.rvm.io | bash -s stable

Add your user account to the rvm group.

# usermod -a -G rvm username

Log out of your terminal, then log back in again. Group memberships are only evaluated at login time.

To start using RVM you need to run following command:

# source /etc/profile.d/rvm.sh

Check the RVM version.

# rvm -v

Output:

rvm 1.29.10 (latest) by Michal Papis, Piotr Kuczynski, Wayne E. Seguin [https://rvm.io]

3. Manage your Ruby Environment

List the known Ruby versions

# rvm list known

Install a specific version of Ruby.

# rvm install ruby-2.7.0
# rvm –default use ruby-2.7.0

Remove a specific version of Ruby.

# rvm remove ruby-2.7.0

Check the Ruby versions installed with RVM.

# rvm list

Check the Ruby version.

# ruby -v

Remove a specific version of Ruby.

# rvm remove ruby-2.7.0

Uninstall RVM

To remove RVM, use following commands

# rvm implode
# rm -rf ~/.rvm
# rm -rf /etc/rvmrc
# rm -rf ~/.rvmrc
# groupdel rvm

Delete RVM source lines from all .bashrc, .bash_profile, .profile, and .zshrc files.

Reboot

That’s it. We have seen how it is easy to install Ruby with RVM on Ubuntu 20.04.

 

Related Articles