IRB(1)
π 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 ofirb. that's the whole job π-E external[:internal],--encoding external[:internal]β same asruby -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 asruby -I. it specifies the$LOAD_PATHdirectory.-Uβ same asruby -U. sets the default value for internal encodings (Encoding.default_internal) toUTF-8.-dβ same asruby -d. sets$DEBUGtotrue. debug mode: activated π-fβ suppresses reading of~/.irbrc. like "not today, config file".-wβ same asruby -w.-Wβ same asruby -W.-h,--helpβ prints a summary of the options. the literal cheat sheet, we love her π«Ά-r libraryβ same asruby -r. it causesirbto load the library usingrequire.--inspectβ usesinspectfor output (this is the default, except for bc mode).--noinspectβ doesn't useinspectfor 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 aredefault,simple,xmpandinf-ruby.--inf-ruby-modeβ uses a prompt appropriate forinf-ruby-modeon emacs. it also suppresses--multilineand--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 topnand tailn. the default value is16.
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 forirb.IRBRCβ the path to the personal initialization file.XDG_CONFIG_HOMEβirbrespectsXDG_CONFIG_HOME. if it's set andIRBRCis unset, then$XDG_CONFIG_HOME/irb/irbrcgets 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 ifRI_PAGERis unset. backup pager energy.VISUALβ its value would be used to open files by theeditcommand.EDITORβ its value would be used to open files by theeditcommand ifVISUALis unset.NO_COLORβ assigning a value to it disables colorization. π tragic, but respect.IRB_USE_AUTOCOMPLETEβ assigningfalseto it disables autocompletion.IRB_COMPLETORβ autocompletion behavior. the allowed values areregexportype. (yes, the spelling isCOMPLETOR, 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β personalirbinitialization. ifIRBRCis set, read$IRBRCinstead. ifIRBRCis not set andXDG_CONFIG_HOMEis set,$XDG_CONFIG_HOME/irb/irbrcis 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