Installing Ruby
Getting a working Ruby environment set up on your machine, and why a version manager beats a system-wide install.
2 min read
Before writing any Ruby, you need the interpreter installed. How you install it matters more than it might seem — Ruby projects often pin specific versions, and fighting your operating system's built-in Ruby is a classic source of early frustration.
Don't use your OS's system Ruby
macOS and many Linux distributions ship with a Ruby already installed, often an old one used internally by the OS itself. Installing gems into it or changing its version can break system tools. The standard fix is a version manager that installs Ruby versions in your home directory, isolated from the system.
The two most common choices are rbenv and mise (formerly rtx); rvm is older but still around. They all do roughly the same job: let you install multiple Ruby versions and switch between them per-project.
# macOS, using Homebrew + rbenv
brew install rbenv
rbenv init
rbenv install 3.3.0
rbenv global 3.3.0On Windows, the simplest path is RubyInstaller, which bundles Ruby and the DevKit needed to compile native gem extensions.
Verify the install
ruby -v
# ruby 3.3.0 (2023-12-25 revision xxxxxxx) [x86_64-darwin23]If that prints a version instead of "command not found," you're set. It's worth checking gem -v too — gem is Ruby's package manager, and it ships alongside the interpreter.
gem -v
# 3.5.3Your first interactive session
Ruby ships with irb (Interactive Ruby), a REPL (read-eval-print loop) for trying things out without creating a file.
irb
irb(main):001:0> 2 + 2
=> 4
irb(main):002:0> "hello".reverse
=> "olleh"
irb(main):003:0> exitirb is where you'll test small snippets throughout this course — it's faster than creating a .rb file for a one-line experiment, and it's how most Rubyists explore an unfamiliar method or class.
Picking a version
Ruby follows semantic-ish versioning with major releases roughly annually. Unless a project specifies otherwise, install the latest stable release — recent versions (3.x) include real performance improvements (like YJIT, a just-in-time compiler) over older 2.x releases, with no downside for learning. If you later work on an existing project, check for a .ruby-version file in its root; that's the version your version manager should switch to for that directory.
With Ruby installed and irb working, you're ready to write actual code.
Test what you just learned
4 quick questions. Get all of them right to unlock the next lesson.
You can take the quiz without an account — logging in just lets your result count toward your progress.