100% Free Forever
AI-Powered Learning
Industry Expert Content
Certificates & Badges
Learn At Your Own Pace
Ruby

Installing Ruby and Using IRB

How to install Ruby with a version manager, verify your setup, and use IRB (Interactive Ruby) to experiment with code in real time.

Ruby FoundationsBeginner7 min readJul 9, 2026
Analogies

Installing Ruby and Using IRB

Before writing any Ruby code, you need a working Ruby installation and a way to experiment quickly. Most developers install Ruby through a version manager rather than a system package manager, because Ruby projects frequently pin specific versions, and a version manager lets you switch between them without conflicts. Once Ruby is installed, IRB (Interactive Ruby), Ruby's built-in read-eval-print loop (REPL), lets you type expressions and see results immediately, making it an essential tool for learning the language and debugging small snippets.

🏏

Cricket analogy: Before you can face a delivery in a match you need proper kit fitted to your height, and a net session lets you try shots quickly; Ruby install is the kit, IRB is the net session for testing shots before the real innings.

Choosing a Version Manager

The two most common Ruby version managers are rbenv and RVM. rbenv is lightweight and does one thing well: it manages which Ruby version is active per shell or per directory, delegating actual installation to the ruby-build plugin. RVM is older and more feature-rich, also managing gemsets, but is heavier. A newer, faster option gaining popularity is mise (formerly rtx), which manages multiple language runtimes including Ruby. Whichever you choose, avoid relying solely on the OS-bundled Ruby, since it is often outdated and modifying it can break system tools that depend on it.

🏏

Cricket analogy: Choosing rbenv over RVM is like a franchise picking a lean specialist bowling coach who focuses only on line and length versus a full support staff that also handles fitness and diet, both valid but different scopes.

ruby
# Typical installation flow using rbenv (run in a terminal, not IRB)
# $ rbenv install 3.3.0
# $ rbenv global 3.3.0
# $ ruby -v
# => ruby 3.3.0 (2023-12-25 revision xxxx) [x86_64-linux]

# Starting IRB from the terminal:
# $ irb
# irb(main):001:0> 2 + 2
# => 4
# irb(main):002:0> "ruby".capitalize
# => "Ruby"

Working Effectively in IRB

IRB evaluates each line you enter and prints its return value, prefixed with =>. This makes it ideal for testing method behavior, exploring an unfamiliar object's API, or checking how a piece of syntax parses. You can inspect an object's available methods with .methods, check its class with .class, and load an external file with load or require_relative. Modern Ruby (3.0+) ships an improved IRB with multiline editing, autocomplete, and colorized output, making it far more pleasant than earlier versions.

🏏

Cricket analogy: IRB showing => after each line is like a scoreboard instantly updating after every ball, letting you check a player's stats or the match state on demand, the way .methods or .class reveal an object's full profile.

IRB is Ruby's equivalent of Python's interactive shell or Node's REPL. A more feature-rich alternative, Pry, adds syntax highlighting, a powerful debugger, and object introspection tools, and many Ruby developers install it as a drop-in replacement for daily work.

Pasting multi-line code with existing indentation into IRB can sometimes trigger confusing parse states, especially in older IRB versions. If IRB seems 'stuck' waiting for more input, type end or press Ctrl+C to reset the prompt.

  • Use a version manager like rbenv, RVM, or mise instead of relying on the OS-bundled Ruby.
  • rbenv pairs with the ruby-build plugin to install and switch Ruby versions per project.
  • Run ruby -v to confirm your active Ruby version after installation.
  • IRB is Ruby's built-in REPL, launched by typing irb in a terminal.
  • IRB prints each expression's return value with a => prefix, making it great for quick experimentation.
  • Pry is a popular enhanced alternative to IRB with better introspection and debugging tools.

Practice what you learned

Was this page helpful?

Topics covered

#Ruby#RubyStudyNotes#Programming#InstallingRubyAndUsingIRB#Installing#IRB#Choosing#Version#StudyNotes#SkillVeris