Skip to content

Ruby Installation Guide — Set Up Ruby on Linux, macOS and Windows

DodaTech Updated 2026-06-28 7 min read

In this tutorial, you will learn about Ruby Installation Guide. We cover key concepts, practical examples, and best practices to help you master this topic.

Ruby installation requires choosing a version manager like rbenv or RVM to manage multiple Ruby versions, along with understanding irb (interactive Ruby) and the gem package manager.

What You'll Learn

  • How to install Ruby on Linux, macOS, and Windows
  • Version managers: rbenv vs RVM — which to choose
  • The interactive Ruby console (irb) and its features
  • How to install gems and manage packages
  • Setting up a development environment for Rails

Why Installation Setup Matters

A proper Ruby installation prevents version conflicts and ensures your development environment matches production. Security tools like Durga Antivirus Pro rely on specific Ruby versions for their automation scripts. Doda Browser uses Ruby-based tooling that requires exact version compatibility. A well-configured environment saves hours of debugging.

Real-World Use

Every Ruby developer needs a reliable setup. Whether you're building a Rails web app, a Jekyll static site, or automation scripts with Sinatra, the installation is your foundation. Professional teams use version managers to maintain consistent environments across development, CI, and production.

flowchart LR
    A["Install Ruby"] --> B["Choose Version Manager"]
    B --> C["Install Ruby Version"]
    C --> D["Configure Gems"]
    D --> E["First Program"]
    A:::current --> B
    style A fill:#2563eb,stroke:#2563eb,color:#fff
    style B fill:#dbeafe,stroke:#2563eb,color:#1e40af
    style C fill:#dbeafe,stroke:#2563eb,color:#1e40af
    style D fill:#dbeafe,stroke:#2563eb,color:#1e40af
    style E fill:#dbeafe,stroke:#2563eb,color:#1e40af

Installing Ruby with a Version Manager

Using a version manager is the recommended approach because it lets you install multiple Ruby versions and switch between them easily.

rbenv is lightweight and follows the Unix philosophy of doing one thing well. It's the most popular choice among Rails developers.

# Install rbenv and ruby-build on Ubuntu/Debian
sudo apt update
sudo apt install git curl libssl-dev libreadline-dev zlib1g-dev autoconf bison build-essential libyaml-dev libreadline-dev libncurses5-dev libffi-dev libgdbm-dev

# Clone rbenv
git clone https://github.com/rbenv/rbenv.git ~/.rbenv

# Add to shell
echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bashrc
echo 'eval "$(rbenv init -)"' >> ~/.bashrc
source ~/.bashrc

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

# Install Ruby 3.3
rbenv install 3.3.0
rbenv global 3.3.0

On macOS:

brew install rbenv ruby-build
rbenv install 3.3.0
rbenv global 3.3.0

RVM (Alternative)

RVM provides more features but is heavier than rbenv:

# Install RVM
gpg --keyserver keyserver.ubuntu.com --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3
\curl -sSL https://get.rvm.io | bash -s stable
source ~/.rvm/scripts/rvm

# Install Ruby
rvm install 3.3.0
rvm use 3.3.0 --default

Which One Should You Choose?

Feature rbenv RVM
Complexity Minimal Full-featured
Ruby installation Via ruby-build plugin Built-in
Gemsets No (use Bundler) Yes
Speed Faster Slightly slower
Community Most popular Established

For most users, rbenv is recommended. It's simpler, faster, and pairs well with Bundler for gem management.

Installing Ruby Without a Version Manager

If you just want Ruby quickly, use your system package manager:

# Ubuntu/Debian
sudo apt install ruby-full

# macOS (built-in but old version)
# Better to use rbenv or RVM

# Windows
# Download RubyInstaller from rubyinstaller.org

Verifying the Installation

After installation, verify everything works:

ruby --version
# ruby 3.3.0 (2023-12-25 revision 5124f9ac75) [x86_64-linux]

irb --version
# irb 1.8.0

gem --version
# 3.5.3

Your First Ruby Program

Create a file called hello.rb:

puts "Hello, Ruby World!"
puts "Ruby version: #{RUBY_VERSION}"
puts "Today is: #{Time.now.strftime('%B %d, %Y')}"

Run it:

ruby hello.rb

Output:

Hello, Ruby World!
Ruby version: 3.3.0
Today is: June 28, 2026

Interactive Ruby (irb)

irb is Ruby's interactive console — your playground for experimenting with code:

irb
irb(main):001> puts "Testing Ruby"
Testing Ruby
=> nil
irb(main):002> 5 + 3
=> 8
irb(main):003> "hello".upcase
=> "HELLO"
irb(main):004> exit

irb Tips

  • Use Tab for autocompletion
  • Press Ctrl+R for history search
  • Use _ to access the last result
  • help shows available commands
# In irb
puts RUBY_VERSION
# 3.3.0

puts RUBY_PLATFORM
# x86_64-linux

puts __FILE__
# (irb)

The Gem Package Manager

Ruby uses gem to install packages (called "gems"):

# Install a gem
gem install sinatra

# List installed gems
gem list

# Search for a gem
gem search rails

# Uninstall a gem
gem uninstall sinatra

# Update all gems
gem update

Gemfile and Bundler

For real projects, use Bundler to manage dependencies:

gem install bundler

Create a Gemfile:

source "https://rubygems.org"

gem "sinatra"
gem "puma"
gem "rspec"

Install all gems:

bundle install

Setting Up for Rails Development

If you plan to use Ruby on Rails, install additional dependencies:

# Install Node.js for the JavaScript runtime
# Install Yarn for asset pipeline
gem install rails --no-document
rails --version
# Rails 7.2.0

Common Installation Issues

1. Permission Denied When Installing Gems

# Don't use sudo with gem install
gem install --user-install sinatra

2. OpenSSL Issues

# Install libssl-dev first
sudo apt install libssl-dev
rbenv install 3.3.0

3. Readline Not Found

sudo apt install libreadline-dev

4. Bundler: Gem Not Found

Always run bundle install after cloning a project and check your Gemfile source:

bundle install
bundle exec ruby app.rb  # Use bundle exec to ensure correct gems

5. Multiple Ruby Versions Conflicting

# Check which ruby you're using
which ruby
rbenv version

# Switch version
rbenv global 3.3.0
rbenv rehash

6. irb Not Found After Installation

# Rehash rbenv shims
rbenv rehash

Practice Questions

1. What command checks your Ruby version?

ruby --version or ruby -v.

2. What's the difference between rbenv and RVM?

rbenv is lightweight and does one thing (version management) well. RVM is heavier and includes features like gemsets. rbenv is recommended for most users.

3. How do you enter Ruby's interactive console?

Type irb in your terminal. Exit with exit or Ctrl+D.

4. What file format does Bundler use to manage gem dependencies?

A Gemfile in the project root directory, listing gem sources and dependencies.

Challenge: Install Ruby using your preferred version manager, then create a Gemfile with three gems of your choice, run bundle install, and verify the gems are available in irb.

Solution
# Install Ruby with rbenv
rbenv install 3.3.0
rbenv global 3.3.0

# Create Gemfile
echo 'source "https://rubygems.org"
gem "sinatra"
gem "puma"
gem "rspec"
gem "json"' > Gemfile

# Install
gem install bundler
bundle install

# Verify
irb -r sinatra -e "puts Sinatra::VERSION"

FAQ

{{< faq question="Should I use rbenv or RVM for Ruby installation?" >}} Use rbenv for most cases. It's simpler, faster, and follows Unix philosophy. RVM is useful if you need gemsets (isolated gem collections), but most developers now use Bundler for that purpose. {{< /faq >}}

{{< faq question="Why do I need a version manager at all?" >}} Different projects require different Ruby versions. A version manager lets you install and switch between versions seamlessly. Without it, you'd have to uninstall and reinstall Ruby whenever a project requires a different version. {{< /faq >}}

{{< faq question="How do I update Ruby to the latest version?" >}} With rbenv: rbenv install 3.3.0 && rbenv global 3.3.0 && rbenv rehash. With RVM: rvm install 3.3.0 && rvm use 3.3.0 --default. {{< /faq >}}

{{< faq question="What's the difference between gem install and bundler?" >}} gem install installs a gem globally. Bundler (via bundle install) installs gems listed in your Gemfile and ensures every developer on the project uses the same versions. Always use Bundler for projects with a Gemfile. {{< /faq >}}

{{< faq question="Do I need Rails to use Ruby?" >}} No. Ruby is a general-purpose language used for scripting, automation, web development, and more. Rails is one framework among many. You can write Ruby programs without ever touching Rails. {{< /faq >}}

Try It Yourself

Create a Ruby version information script:

# version_info.rb
puts "=" * 50
puts "RUBY ENVIRONMENT INFO"
puts "=" * 50
puts "Ruby Version:    #{RUBY_VERSION}"
puts "Ruby Patchlevel: #{RUBY_PATCHLEVEL}"
puts "Ruby Platform:   #{RUBY_PLATFORM}"
puts "Ruby Engine:     #{RUBY_ENGINE}"
puts "Engine Version:  #{RUBY_ENGINE_VERSION}"
puts "Release Date:    #{RUBY_RELEASE_DATE}"
puts "=" * 50
puts "Gem Path:"
puts Gem.path.join("\n")
puts "=" * 50
puts "Loaded Gems:"
Gem::Specification.each do |spec|
  puts "  - #{spec.name} (#{spec.version})"
end

Expected output:

==================================================
RUBY ENVIRONMENT INFO
==================================================
Ruby Version:    3.3.0
Ruby Patchlevel: 0
Ruby Platform:   x86_64-linux
Ruby Engine:     ruby
Engine Version:  3.3.0
Release Date:    2023-12-25
==================================================
Gem Path:
/home/user/.rbenv/versions/3.3.0/lib/ruby/gems/3.3.0
==================================================
Loaded Gems:
  - bundler (2.5.3)
  - ...

What's Next

With Ruby installed, you're ready to learn about variables, data types, and how to store and manipulate data in your programs.

Topic Description Link
Ruby Variables & Types Dynamic typing, symbols, strings {{< ref "03-variables-types" >}}
Ruby Control Flow Conditionals and logic {{< ref "04-control-flow" >}}
Python Installation Compare with Python setup Python

Built by the developers of DodaTech

Doda Browser, DodaZIP & Durga Antivirus Pro