IRB(1)

πŸ“¦ version 3.2.3, in ubuntu noble

✨ IRB(1) ✨

okay so bestie, welcome to irb, the Interactive Ruby Shell β€” this is the page for it in the Ruby Programmer's Reference Guide, and honestly? it's giving main character energy for every Ruby dev's terminal. πŸŽ€


πŸ’– NAME πŸ’–

irb β€” Interactive Ruby Shell. that's it, that's the name, short and iconic. πŸ’…


πŸ¦‹ SYNOPSIS πŸ¦‹

irb [--version] [-dfUw] [-I directory] [-r library]
    [-E external[:internal]] [-W[level]] [--[no]inspect]
    [--[no]multiline] [--[no]singleline] [--[no]echo] [--[no]colorize]
    [--[no]autocomplete] [--[no]verbose] [--prompt mode]
    [--prompt-mode mode] [--inf-ruby-mode] [--simple-prompt]
    [--noprompt] [--tracer] [--back-trace-limit n] [--] [program_file]
    [argument ...]

like yes, that's a lot of flags. we'll get to every single one, don't worry bestie 🫢


🌸 DESCRIPTION 🌸

irb is the REPL (read-eval-print loop) environment for Ruby programs. you type Ruby, it reads it, evaluates it, prints the result, and loops back around to let you do it again. it's the little conversation you have with your code and ngl it's kind of the best part of the language. πŸ’œ


πŸ’… OPTIONS πŸ’…

every flag, every one, no skips, no cap. ✨

  • --version β€” Prints the version of irb.
  • -E external[:internal]
  • --encoding external[:internal] β€” Same as ruby -E. Specifies the default value(s) for external encodings and internal encoding. Values should be separated with colon (:).

You can omit the one for internal encodings, then the value (Encoding.default_internal) will be nil. so if you leave that part off, bestie, you get nil β€” that's just the deal.

  • -I path β€” Same as ruby -I. Specifies $LOAD_PATH directory
  • -U β€” Same as ruby -U. Sets the default value for internal encodings (Encoding.default_internal) to UTF-8.
  • -d β€” Same as ruby -d. Sets $DEBUG to true.
  • -f β€” Suppresses read of ~/.irbrc. no personal config today, we're going in fresh πŸ’«
  • -w β€” Same as ruby -w.
  • -W β€” Same as ruby -W.
  • -h
  • --help β€” Prints a summary of the options.
  • -r library β€” Same as ruby -r. Causes irb to load the library using require.
  • --inspect β€” Uses inspect for output (default except for bc mode)
  • --noinspect β€” Doesn't use inspect for output
  • --multiline β€” Uses multiline editor module.
  • --nomultiline β€” Doesn't use multiline editor module.
  • --singleline β€” Uses singleline editor module.
  • --nosingleline β€” Doesn't use singleline editor module.
  • --extra-doc-dir β€” Add an extra doc dir for the doc dialog.
  • --echo β€” Show result (default). the default! so you already have it, slay
  • --noecho β€” Don't show result.
  • --echo-on-assignment β€” Show result on assignment.
  • --noecho-on-assignment β€” Don't show result on assignment.
  • --truncate-echo-on-assignment β€” Show truncated result on assignment (default).
  • --colorize β€” Use colorization. 🌈
  • --nocolorize β€” Don't use colorization.
  • --autocomplete β€” Use autocompletion.
  • --noautocomplete β€” Don't use autocompletion.
  • --verbose β€” Show details.
  • --noverbose β€” Don't show details.
  • --prompt mode
  • --prompt-mode mode β€” Switch prompt mode. Pre-defined prompt modes are default, simple, xmp and inf-ruby.
  • --inf-ruby-mode β€” Uses prompt appropriate for inf-ruby-mode on emacs. Suppresses --multiline and --singleline. not me suppressing two other flags at once 😭
  • --simple-prompt β€” Makes prompts simple.
  • --noprompt β€” No prompt mode.
  • --tracer β€” Displays trace for each execution of commands.
  • --back-trace-limit n β€” Displays backtrace top n and tail n. The default value is 16.

πŸ“ ENVIRONMENT πŸ“

  • IRB_LANG β€” The locale used for irb.
  • IRBRC β€” The path to the personal initialization file.
  • XDG_CONFIG_HOME β€” irb respects XDG_CONFIG_HOME. If this is set, load $XDG_CONFIG_HOME/irb/irbrc as a personal initialization file.

Also irb depends on same variables as ruby(1). iykyk β€” check that page too bestie 🫢


🧚 FILES 🧚

  • ~/.irbrc β€” Personal irb initialization. If IRBRC is set, read $IRBRC instead. If IRBRC is not set and XDG_CONFIG_HOME is set, $XDG_CONFIG_HOME/irb/irbrc is loaded.

⭐ EXAMPLES ⭐

okay here's the whole vibe in one session, look how cute this is πŸ‘‘

      % irb
      irb(main):001:0> 1 + 1
      2
      irb(main):002:0> def t(x)
      irb(main):003:1> x + 1
      irb(main):004:1> end
      => :t
      irb(main):005:0> t(3)
      => 4
      irb(main):006:0> if t(3) == 4
      irb(main):007:1> p :ok
      irb(main):008:1> end
      :ok
      => :ok
      irb(main):009:0> quit
      %

the prompt even tells you what's going on β€” line number, nesting level, the whole lore. obsessed. πŸ’–


πŸ” SEE ALSO πŸ”


🚨 REPORTING BUGS 🚨

bestie, please read this part, it actually matters πŸ™ˆ
  • Security vulnerabilities should be reported via an email to security@ruby-lang.org. Reported problems will be published after being fixed.
  • Other bugs and feature requests can be reported via the Ruby Issue Tracking System (https://bugs.ruby-lang.org/). Do not report security vulnerabilities via this system because it publishes the vulnerabilities immediately.
fr fr, do NOT drop a security vuln in the public tracker, it gets published instantly and that's a whole mess. πŸ’€

πŸ‘‘ AUTHORS πŸ‘‘

Written by Keiju ISHITSUKA. 🫢


and that's the page!! this one came out under the UNIX manual set, dated August 11, 2019 β€” so like, go open a terminal, run irb, and have the best time. mwah πŸ’‹βœ¨

πŸ“¦ where this page comes from