RackNerd Billboard Banner

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

  1. 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 -
  2. Install RVM:
    curl -sSL https://get.rvm.io | bash -s stable

    source ~/.rvm/scripts/rvm
  3. Install Ruby:
    rvm install ruby

    rvm use ruby --default
  4. Verify Installation:
    ruby -v

Install Ruby with rbenv

  1. Install dependencies:
    sudo apt update

    sudo apt install git curl libssl-dev libreadline-dev zlib1g-dev
  2. 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
  3. Install Ruby:
    rbenv install 3.3.0 # Replace with latest version

    rbenv global 3.3.0
  4. Check Version:
    ruby -v

Troubleshooting

  • If the terminal says ruby: command not found, close and reopen your terminal or run source ~/.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!

0 0 votes
Article Rating
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments
RackNerd Billboard Banner
© 2025 Computer Everywhere
Your Everyday Guide to the Digital World.
Terms of Service | Privacy Policy
Copy link