Your cart is currently empty!
How to Install Ruby on Linux
Ruby is a dynamic, open-source programming language with a strong community and plenty of real-world use. If you’re getting into web development, automation, or scripting, Ruby is a great skill to have. Here’s how to install Ruby on Linux in a few straightforward steps.
Method 1: Install Ruby Using Your Linux Package Manager
This is the quickest way to get Ruby up and running, but you might not get the absolute latest version.
For Ubuntu/Debian:
sudo apt update
sudo apt install ruby-full
For Fedora:
sudo dnf install ruby
For CentOS/RHEL:
sudo yum install ruby
After installation, check your Ruby version:
ruby -v
Method 2: Install Ruby Using a Version Manager
If you want more control—especially if you need multiple Ruby versions—use a version manager like RVM or rbenv.
Install Ruby with RVM
- Install GPG Keys:
sudo apt update
sudo apt install curl gpg
curl -sSL https://rvm.io/mpapis.asc | gpg --import -
curl -sSL https://rvm.io/pkuczynski.asc | gpg --import -
- Install RVM:
curl -sSL https://get.rvm.io | bash -s stable
source ~/.rvm/scripts/rvm
- Install Ruby:
rvm install ruby
rvm use ruby --default
- Verify Installation:
ruby -v
Install Ruby with rbenv
- Install dependencies:
sudo apt update
sudo apt install git curl libssl-dev libreadline-dev zlib1g-dev
- Install rbenv and ruby-build:
git clone https://github.com/rbenv/rbenv.git ~/.rbenv
cd ~/.rbenv && src/configure && make -C src
echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bashrc
echo 'eval "$(rbenv init -)"' >> ~/.bashrc
source ~/.bashrc
git clone https://github.com/rbenv/ruby-build.git ~/.rbenv/plugins/ruby-build
- Install Ruby:
rbenv install 3.3.0 # Replace with latest version
rbenv global 3.3.0
- Check Version:
ruby -v
Troubleshooting
- If the terminal says
ruby: command not found
, close and reopen your terminal or runsource ~/.bashrc
. - If installation fails, check for missing dependencies and install them using your package manager.
- For Ubuntu, always run
sudo apt update
before installing new packages.
Wrapping Up
That’s it! You’ve got Ruby running on your Linux machine. Whether you use your package manager or a version manager, you’re now set up to start developing with Ruby. If you hit any issues, check the official Ruby documentation for deeper troubleshooting.
Ready to code? Fire up IRB with irb
and start experimenting!
Tech enthusiast and content creator passionate about making technology simple for everyone. I share practical tips, guides, and reviews on the latest in computers, software, and gadgets. Let’s explore the digital world together!