Skip to main content

Install RVM and Ruby on Linux

This guide explains how to install RVM (Ruby Version Manager) and Ruby on Linux.

Prerequisites

Install the packages required to build Ruby. On Debian/Ubuntu:

sudo apt update
sudo apt install -y curl gpg gcc g++ make libssl-dev libreadline-dev zlib1g-dev libyaml-dev libffi-dev

On Fedora/RHEL:

sudo dnf install -y curl gcc gcc-c++ make openssl-devel readline-devel zlib-devel libyaml-devel libffi-devel

On Arch Linux:

sudo pacman -S base-devel openssl readline zlib libyaml libffi

Install RVM

  1. Install the RVM signing key (recommended for security):
gpg --keyserver keyserver.ubuntu.com --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3 7D2BAF1CF37B13E2069D6956105BD0E739499BDB
  1. Install RVM (stable version):
curl -sSL https://get.rvm.io | bash -s stable
  1. Load RVM in your current shell:
source ~/.rvm/scripts/rvm

To load RVM automatically in new shells, ensure your shell config (e.g. ~/.bashrc or ~/.zshrc) contains:

source ~/.rvm/scripts/rvm

The installer usually adds this for you. If not, add it manually and run source ~/.bashrc (or your config file).

Install Ruby

  1. List available Ruby versions (optional):
rvm list known
  1. Install the latest stable Ruby:
rvm install ruby

Or install a specific version, for example 3.3:

rvm install 3.3
  1. Set the default Ruby (if you have multiple versions):
rvm use 3.3 --default
  1. Verify the installation:
ruby --version
gem --version

Quick reference

TaskCommand
Install RVMcurl -sSL https://get.rvm.io \| bash -s stable
Load RVMsource ~/.rvm/scripts/rvm
Install Rubyrvm install ruby
Install specificrvm install 3.3
Set defaultrvm use 3.3 --default
List installedrvm list
List availablervm list known

Troubleshooting

  • "RVM is not a function"
    Run source ~/.rvm/scripts/rvm or open a new terminal after ensuring your shell config loads RVM.

  • Build errors when installing Ruby
    Install the prerequisite dev packages for your distro (see Prerequisites above) and try again.

  • Permission errors
    Install RVM in your user directory (as in this guide); avoid using sudo with RVM.