Support Online
Skip to main content

Installing Ruby on Rails with RVM on Ubuntu 20.04

🧠 Technical Summary

This guide describes how to install Ruby on Rails using RVM (Ruby Version Manager) on Ubuntu 20.04**. The goal is to offer developers the ability to manage multiple Ruby/Rails versions in isolation in the same environment. Steps; It covers adding GPG key, installing RVM, installing Rails, version management, installing Node.js, and optional uninstallation.


🛠️ What Will You Learn in This Guide?

Thanks to this guide:

  • How to manage Ruby and Rails installation with RVM,
  • How to switch between different Ruby/Rails versions,
  • Node.js installation required for some Rails features,
  • You will learn to safely remove RVM from the system when necessary.

⚙️ Step by Step Installation Process

Before starting these operations, log in to your server with a non-root user with sudo authority.


1. Installing RVM and Installing Rails

Update GPG:

sudo apt update
sudo apt install gnupg2

📝 This command installs the GPG tool, it is required to verify RVM keys.

Get RVM Key:

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

📝 This step verifies that the RVM installation is safe.

Download and Run RVM Script:

\curl -sSL https://get.rvm.io -o rvm.sh
cat rvm.sh | bash -s stable --rails

📝 This command installs RVM and the latest stable Ruby & Rails version.

Add RVM Scripts to Source:

source ~/.rvm/scripts/rvm

📝 Now your Ruby on Rails development environment is ready.


2. Installing and Managing Specific Versions

Viewing Available Ruby Versions:

rvm list known

Installing Specific Version:

rvm install 3.0.0

Version Changing:

rvm use 3.0.0

Installing Specific Rails Version:

gem install rails -v 7.0.2

📝 This command installs the selected Rails version.

Gemset Creation (Advanced):

rvm gemset create projemin_seti
rvm 3.0.0@projemin_seti --create

📝 This step creates isolated environments for different projects.


3. Node.js Installation (Optional)

Some Rails projects require Node.js to compile JavaScript.

Download Node.js Script:

\curl -sSL https://deb.nodesource.com/setup_17.x -o nodejs.sh
cat nodejs.sh | sudo -E bash -

Node.js Installation:

sudo apt update
sudo apt install nodejs

📝 This command installs Node.js v17.x.


4. Uninstalling RVM (Optional)

If you want to stop using RVM:

Delete RVM Rows:

nano ~/.bashrc

Remove the following lines:

# Add RVM to PATH for scripting.
export PATH="$PATH:$HOME/.rvm/bin"

Remove RVM Directory:

rm -rf ~/.rvm

📝 This process completely deletes RVM and related files.


❓ Frequently Asked Questions (FAQ)

1. Why is RVM necessary?

It allows you to use multiple Ruby versions on the same system without conflict.

2. What is Gemset?

Gemset is a mini-environment that isolates dependencies specific to each Ruby version.

3. I get the error “GPG key not found”, what should I do?

Run the command again or try a different keyserver (example: hkps://keys.openpgp.org).

4. Does Rails always require Node.js?

New Rails versions use importmaps, but some older projects require Node.js.

5. What should I do for security on the cloud server?

Just open port 3000 in developer mode, run it behind Nginx or Apache in production.


🎯 Result

Congratulations! You have successfully installed Ruby on Rails with RVM on your Ubuntu 20.04 server. You can now seamlessly manage multiple Ruby and Rails versions on a single machine and add Node.js integration.

💡 Try your Ruby on Rails apps on high-performance Ubuntu instances on the GenixNode platform now!