123456789_123456789_123456789_123456789_123456789_

Configure IRB

Configuration Sources

IRB configurations can be set through multiple sources, each with its own precedence:

  1. Command-Line Options: When some options are specified when starting IRB, they can override default settings.
  2. Configuration File: If present, IRB reads a configuration file containing Ruby code to set configurations.
  3. Environment Variables: Certain environment variables influence IRB's behavior.
  4. Hash IRB.conf: This hash holds the current configuration settings, which can be modified during a session.

Configuration File Path Resolution

IRB searches for a configuration file in the following order:

  1. $IRBRC
  2. $XDG_CONFIG_HOME/irb/irbrc
  3. $HOME/.irbrc
  4. $HOME/.config/irb/irbrc
  5. .irbrc in the current directory
  6. irb.rc in the current directory
  7. _irbrc in the current directory
  8. $irbrc in the current directory

If the -f command-line option is used, no configuration file is loaded.

Method conf.rc? returns true if a configuration file was read, false otherwise. Hash entry IRB.conf[:RC] also contains that value.

Environment Variables

Hash IRB.conf

The initial entries in hash IRB.conf are determined by:

You can see the hash by typing IRB.conf. Below are the primary entries: