Installing Ruby on Your Computer

· 8 min read · beginner
installation setup beginner rbenv rvm

Ruby is a versatile programming language powering everything from web applications to automation scripts. Before you can start writing Ruby code, you need to get Ruby installed on your machine. This tutorial walks you through installing Ruby on macOS, Linux, and Windows using the most reliable methods.

Why Ruby?

Ruby was designed to make developers happy. Its elegant syntax reads like natural English, and its philosophy of “convention over configuration” has influenced countless frameworks—including Ruby on Rails, one of the most popular web frameworks in the world.

Whether you’re building web applications with Rails, scripting automation tasks, or learning programming for the first time, Ruby is an excellent choice.

Installing Ruby on macOS

macOS comes with Ruby pre-installed, but it’s often an older version. For development, you’ll want a newer, manageable version.

Homebrew is the macOS package manager that makes installing development tools straightforward.

First, install Homebrew if you haven’t already:

/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"

Then install Ruby:

brew install ruby

Homebrew installs Ruby to /usr/local/bin or /opt/homebrew/bin, which takes precedence over the system Ruby. To use Homebrew’s Ruby by default, add this to your shell configuration file (~/.zshrc for Zsh or ~/.bash_profile for Bash):

export PATH="/usr/local/opt/ruby/bin:$PATH"
# For Apple Silicon Macs:
# export PATH="/opt/homebrew/opt/ruby/bin:$PATH"

Then restart your terminal or run:

source ~/.zshrc

Method 2: Using rbenv

rbenv is a lightweight version manager that lets you switch between Ruby versions easily. It’s perfect when you need to test your code against different Ruby versions.

Install rbenv and ruby-build:

brew install rbenv ruby-build

Add rbenv to your shell:

echo 'eval "$(rbenv init -)"' >> ~/.zshrc
source ~/.zshrc

Install a recent Ruby version:

rbenv install 3.4.1
rbenv global 3.4.1

Verify the installation:

ruby --version

Method 3: Using RVM

RVM (Ruby Version Manager) is another popular option that handles Ruby versions and gem sets comprehensively.

Install RVM:

\curl -sSL https://get.rvm.io | bash -s stable
source ~/.rvm/scripts/rvm

Install Ruby:

rvm install 3.4.1
rvm use 3.4.1 --default

Installing Ruby on Linux

Linux users have several options depending on your distribution.

Ubuntu and Debian

The easiest approach is using rbenv for better version control:

# Install dependencies
sudo apt update
sudo apt install git curl libssl-dev libreadline-dev zlib1g-dev autoconf bison build-essential libyaml-dev libncurses5-dev libffi-dev libgdbm-dev

# Install rbenv
git clone https://github.com/rbenv/rbenv.git ~/.rbenv
echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bashrc
echo 'eval "$(rbenv init -)"' >> ~/.bashrc
source ~/.bashrc

# Install ruby-build
git clone https://github.com/rbenv/ruby-build.git ~/.rbenv/plugins/ruby-build

# Install Ruby
rbenv install 3.4.1
rbenv global 3.4.1

Fedora

sudo dnf install ruby ruby-devel

Arch Linux

sudo pacman -S ruby

Installing Ruby on Windows

Windows doesn’t have native Ruby support, but several tools make it straightforward.

RubyInstaller provides a complete Ruby environment for Windows with just a few clicks:

  1. Download RubyInstaller from rubyinstaller.org
  2. Run the installer
  3. Check “Add Ruby to your PATH”
  4. Complete the installation

After installation, open a new Command Prompt or PowerShell and verify:

ruby --version

Using WSL (Windows Subsystem for Linux)

For the best experience on Windows, consider using WSL:

wsl --install

Once Ubuntu is installed via WSL, follow the Ubuntu installation instructions above. This gives you a full Linux environment where Ruby works natively.

Verifying Your Installation

Regardless of your operating system, verify Ruby is installed correctly:

ruby --version
# Should output something like: ruby 3.4.1p123 (2026-03-06 revision abc123) [your platform]

irb --version
# Interactive Ruby console version

You should see Ruby 3.x or newer.

Running Your First Ruby Script

Now that Ruby is installed, let’s write and run your first program:

Create a file called hello.rb:

# hello.rb
puts "Hello, Ruby!"
puts "Welcome to the Ruby Fundamentals series."

Run it:

ruby hello.rb

You should see:

Hello, Ruby!
Welcome to the Ruby Fundamentals series.

Congratulations—you’ve run your first Ruby program!

The Ruby Ecosystem: Gems

Ruby packages are called gems. The RubyGems package manager comes bundled with Ruby. Let’s verify it’s working:

gem --version

Update gem to the latest version:

gem update --system

Installing gems is simple:

gem install bundler

Bundler manages gem dependencies for your projects, ensuring consistent environments across different machines.

Choosing Your Installation Method

For most developers, here’s the recommended approach:

  • macOS: Use Homebrew for simplicity, or rbenv if you need multiple Ruby versions
  • Linux: Use rbenv for version flexibility, or your distribution’s package manager for system Ruby
  • Windows: Use RubyInstaller or WSL for the best experience

Now that Ruby is installed, you’re ready to move on to the next tutorial in this series: “Getting Started with Ruby” where you’ll write your first Ruby code and understand the basic syntax.

Troubleshooting

”Ruby not found” error

Ensure Ruby is in your PATH. Check with:

which ruby

If empty, add Ruby to your PATH in your shell configuration file.

Permission denied when installing gems

Never use sudo gem install on macOS or Linux—it can cause permission issues. Instead, either use Homebrew’s Ruby or configure a user gem directory.

Version conflicts

If you have multiple Ruby installations, rbenv or RVM help isolate versions. Use rbenv versions or rvm list to see what’s installed.

Next Steps

With Ruby installed, you’re ready to explore the language:

  1. Test Ruby in IRB (Interactive Ruby Shell): irb
  2. Explore RubyGems: gem list
  3. Continue to the next tutorial: “Getting Started with Ruby”

Ruby provides an incredibly developer-friendly experience, and installation is just the first step. Enjoy the journey!