IRB(1)
π IRB(1) β Ruby Programmer's Reference Guide π
β¨ NAME β¨
okay so the name is irb and it's basically the Interactive Ruby Shell π It's a REPL (read-eval-print loop), so you type Ruby and it reads, runs, and prints the result right back at you. 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 ...]
π¦ DESCRIPTION π¦
so irb is the REPL (read-eval-print loop) environment for Ruby programs. literally where you go to play with Ruby without making a whole file π§
πΈ OPTIONS πΈ
--versionβ shows you the version of irb π·οΈ-E external[:internal],--encoding external[:internal]β same asruby -E. This sets the default external and internal encodings. Separate the two with a colon (:) β¨
you can leave off the internal part, and then Encoding.default_internal just ends up as nil π
-I pathβ same asruby -I. Adds a directory to$LOAD_PATHπ-Uβ same asruby -U. Sets the default internal encoding (Encoding.default_internal) to UTF-8 π-dβ same asruby -d. Sets$DEBUGto true π-fβ skips reading~/.irbrcπ ββοΈ-wβ same asruby -wβ οΈ-Wβ same asruby -Wπ₯-h,--helpβ prints a summary of the options π-r libraryβ same asruby -r. Makes irb load the library usingrequireπ--inspectβ usesinspectfor output. This is the default, except in 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 π--echoβ shows the result (this is the default) π--noechoβ hides the result π«₯--echo-on-assignmentβ shows the result on assignment π--noecho-on-assignmentβ hides the result on assignment π--truncate-echo-on-assignmentβ shows a truncated result on assignment (default) βοΈ--colorizeβ turns on colorization π--nocolorizeβ turns colorization off π©Ά--autocompleteβ turns on autocompletion πͺ--noautocompleteβ turns autocompletion off π ββοΈ--regexp-completorβ uses regexp based completion π§΅--type-completorβ uses type based completion π§--verboseβ shows details π--noverboseβ hides the details π€«--prompt mode,--prompt-mode modeβ switches the prompt mode. The pre-defined ones aredefault,simple,xmpandinf-rubyπ¬--inf-ruby-modeβ uses a prompt that fits inf-ruby-mode on emacs. This one suppresses--multilineand--singlelineπ«Ά
heads up:--inf-ruby-modeturns off--multilineand--singlelinefor you, so don't expect them to stick around.
--simple-promptβ makes the prompts simple π--nopromptβ no prompt mode, so no prompt at all π«--tracerβ displays a trace for each command that runs π΅οΈββοΈ--back-trace-limit nβ displays the topnand the tailnof the backtrace. The default is 16 π§
π ENVIRONMENT π
IRB_LANGβ the locale irb uses πΊοΈIRBRCβ the path to your personal initialization file ποΈXDG_CONFIG_HOMEβ irb respects this one! If it's set, irb loads$XDG_CONFIG_HOME/irb/irbrcas your personal initialization file π
irb also depends on the same variables that ruby(1) does, so keep that in mind π
π FILES π
~/.irbrcβ your personal irb initialization file. IfIRBRCis set, irb reads$IRBRCinstead. IfIRBRCisn't set butXDG_CONFIG_HOMEis, then$XDG_CONFIG_HOME/irb/irbrcgets loaded π
π EXAMPLES π
okay here's a little session so you can see the vibe π
% 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
%
π SEE ALSO π
ruby(1). go read that one too, it's the sister page π―ββοΈ
π¨ REPORTING BUGS π¨
- Security vulnerabilities should be emailed to
security@ruby-lang.org. The problems get published once they're fixed π - Other bugs and feature requests can go to the Ruby Issue Tracking System (
https://bugs.ruby-lang.org/). Please don't report security vulnerabilities there though, because that system publishes them immediately π ββοΈπ
π AUTHORS π
written by Keiju ISHITSUKA. ICONIC π«‘
ok bestie that's the whole page π it came from UNIX, dated August 11, 2019, and it's all about IRB(1) π¦ stay curious, stay caffeinated, and never let a REPL go unexplored β¨π«Ά
π¦ where this page comes from
- debian trixie: ruby3.3 3.3.8-2 Β· BSD-2-Clause OR Ruby
- ubuntu questing: ruby3.3 3.3.8-2ubuntu2
- ubuntu questing: ruby3.3 3.3.8-2ubuntu2.1 Β· BSD-2-Clause OR Ruby
- ubuntu resolute: ruby3.3 3.3.8-2ubuntu3 Β· BSD-2-Clause OR Ruby
- ubuntu resolute: ruby3.3 3.3.8-2ubuntu3.1 Β· BSD-2-Clause OR Ruby
- ubuntu stonking: ruby3.3 3.3.8-2.2ubuntu4 Β· BSD-2-Clause OR Ruby
- π girlified by anthropic/claude-haiku-5.5 on : a language model's rewrite of the original, under its terms