IRB(1)

πŸ“¦ version 4.0.6, in centos-stream 10

πŸ’… IRB(1) β€” your girl's guide to the Interactive Ruby Shell

okay so this is IRB(1), straight out of the Ruby Programmer's Reference Guide, and it's genuinely one of my favorite pages ever. welcome to the group chat, bestie 🫢

✨ NAME ✨

irb β€” Interactive Ruby Shell. that's it. that's the vibe. it's a whole REPL and it's 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, it's a lot of brackets. it's giving "options menu at a fancy restaurant". don't panic, we're gonna go through every single one πŸ’–

🌸 DESCRIPTION 🌸

irb is the REPL (that's read-eval-print loop, bestie) environment for Ruby programs. you type stuff, it evaluates stuff, it prints stuff, and it does it all over again forever. main character energy, truly ✨


πŸŽ€ OPTIONS πŸŽ€

okay buckle up, there are SO many and we're covering all of them, no skipping 🫑

  • --version β€” prints the version of irb. that's the whole job πŸ’…
  • -E external[:internal], --encoding external[:internal] β€” same as ruby -E. it sets the default value(s) for the external encodings and the internal encoding. separate the values with a colon (:), obviously.

you can also skip the internal one entirely, and then that value (Encoding.default_internal) will be nil. no notes, slay.

  • -I path β€” same as ruby -I. it specifies the $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. debug mode: activated πŸ’€
  • -f β€” suppresses reading of ~/.irbrc. like "not today, config file".
  • -w β€” same as ruby -w.
  • -W β€” same as ruby -W.
  • -h, --help β€” prints a summary of the options. the literal cheat sheet, we love her 🫢
  • -r library β€” same as ruby -r. it causes irb to load the library using require.
  • --inspect β€” uses inspect for output (this is the default, except for bc mode).
  • --noinspect β€” doesn't use inspect for output.
  • --multiline β€” uses the multiline editor module.
  • --nomultiline β€” doesn't use the multiline editor module.
  • --singleline β€” uses the singleline editor module.
  • --nosingleline β€” doesn't use the singleline editor module.
  • --extra-doc-dir β€” adds an extra doc dir for the doc dialog. very "one more folder won't hurt" of it.
  • --echo β€” shows the result (this is the default).
  • --noecho β€” doesn't show the result.
  • --echo-on-assignment β€” shows the result on assignment.
  • --noecho-on-assignment β€” doesn't show the result on assignment.
  • --truncate-echo-on-assignment β€” shows a truncated result on assignment (default). keeping it short and cute βœ‚οΈ
  • --colorize β€” uses colorization. pretty colors, obviously πŸ’–
  • --nocolorize β€” doesn't use colorization. monochrome era, I guess.
  • --autocomplete β€” uses autocompletion.
  • --noautocomplete β€” doesn't use autocompletion.
  • --regexp-completor β€” uses regexp based completion.
  • --type-completor β€” uses type based completion.
  • --verbose β€” shows details.
  • --noverbose β€” doesn't show details.
  • --prompt mode, --prompt-mode mode β€” switches the prompt mode. the pre-defined prompt modes are default, simple, xmp and inf-ruby.
  • --inf-ruby-mode β€” uses a prompt appropriate for inf-ruby-mode on emacs. it also suppresses --multiline and --singleline. multitasking icon.
  • --simple-prompt β€” makes prompts simple. lowkey the "no thoughts head empty" setting.
  • --noprompt β€” no prompt mode at all.
  • --tracer β€” displays a trace for each execution of commands. she's watching πŸ‘€
  • --back-trace-limit n β€” displays backtrace top n and tail n. the default value is 16.
also yes, the synopsis has a -- in there, and then [program_file] and [argument ...] after it β€” those are part of the usage line, girlie, don't forget them πŸ’œ

πŸ¦‹ ENVIRONMENT πŸ¦‹

the environment variables, aka the "who's setting what" section:

  • IRB_LANG β€” the locale used for irb.
  • IRBRC β€” the path to the personal initialization file.
  • XDG_CONFIG_HOME β€” irb respects XDG_CONFIG_HOME. if it's set and IRBRC is unset, then $XDG_CONFIG_HOME/irb/irbrc gets loaded as a personal initialization file.
  • RI_PAGER β€” the command specified here would be used as a pager.
  • PAGER β€” the command specified here would be used as a pager if RI_PAGER is unset. backup pager energy.
  • VISUAL β€” its value would be used to open files by the edit command.
  • EDITOR β€” its value would be used to open files by the edit command if VISUAL is unset.
  • NO_COLOR β€” assigning a value to it disables colorization. 😭 tragic, but respect.
  • IRB_USE_AUTOCOMPLETE β€” assigning false to it disables autocompletion.
  • IRB_COMPLETOR β€” autocompletion behavior. the allowed values are regexp or type. (yes, the spelling is COMPLETOR, we don't make the rules πŸ’…)
  • IRB_COPY_COMMAND β€” overrides the default program used to interface with the system clipboard. for all your copy-paste needs πŸ“‹

also irb depends on the same variables as ruby(1).


πŸ“ 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 this is my favorite part, watch her work:

% 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
%

look at those prompt numbers going up. look at that => :t. we love a system that talks back 🫢


🌈 SEE ALSO 🌈

ruby(1). that's the whole list, go say hi to her too.


πŸ’€ REPORTING BUGS πŸ’€

  • security vulnerabilities should be reported via an email to security@ruby-lang.org. reported problems will be published after being fixed. responsible queen behavior.
  • 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. like, immediately immediately. don't do it πŸ™ˆ

πŸ‘‘ AUTHORS πŸ‘‘

written by Keiju ISHITSUKA. legend.


and that's the page, bestie πŸŽ€ this was IRB(1) from the UNIX manual, dated August 11, 2019, and it's sourced from the Ruby Programmer's Reference Guide β€” go forth and REPL responsibly πŸ’–βœ¨

πŸ“¦ where this page comes from
  • centos-stream 10: ruby4.0 4.0.6-37.el10 Β· (Ruby OR BSD-2-Clause) AND (Ruby OR BSD-2-Clause OR GPL-1.0-or-later) AND BSD-3-Clause AND (GPL-3.0-or-later WITH Bison-exception-2.2) AND ISC AND LicenseRef-Fedora-Public-Domain AND MIT AND CC0-1.0 AND zlib AND Unicode-DFS-2015 AND HPND-Markus-Kuhn AND Ruby-pty AND (Ruby OR BSD-2-Clause OR Python-2.0.1) AND BSD-2-Clause AND (Apache-2.0 OR BSL-1.0) AND GPL-2.0-only AND CC-BY-2.5 AND OFL-1.1-RFN AND BSL-1.0
  • πŸ’– girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms