While investigating an issue with irb on my Mac (OS X 10.11.5) I noticed /etc/irbrc
. The first few lines follow:
# Some default enhancements/settings for IRB, based on
# http://wiki.rubygarden.org/Ruby/page/show/Irb/TipsAndTricks
unless defined? ETC_IRBRC_LOADED
# Require RubyGems by default.
require 'rubygems'
# Activate auto-completion.
require 'irb/completion'
# continued ...
It seems to be out of date (rubygarden.org is gone, rubygems is in the standard library these days) and does things that I always thought I had to do in my own ~/.irbrc
(set up completion, history, etc.).
It is dated 31 Jan 2016. I might or might not have run an Apple system update or upgraded something else on that date; I don't recall. I've definitely upgraded OS X by a major version or two since then.
I don't think I have any Rubies installed on this computer other than that from OS X and a Ruby 2.3.1 installed with rbenv (in my own account, not as root). That is, I don't think this file could have come from anything other than OS X.
Unix shell convention would lead me to expect that a file named /etc/irbrc
would be executed when any user ran irb, before their ~/.irbrc
if they had one. However, the irb installed by OS X doesn't appear to read this file: I put puts 1
at the top and don't see the result when I run irb. (I normally use rbenv, but disabled it while investigating this file.) /etc/irbrc
doesn't appear to run whether or not I have an ~/.irbrc
. Also, I see no mentions of this file in /usr/bin/irb
or /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/irb
.
My guess is that this file
- is installed by OS X
- is not read by irb as is (despite its misleading name and location), but is intended to be copied to
~/.irbrc
.
Does anyone know for sure, or know any different?
I don't need or want it; I'm happy to maintain my own ~/.irbrc
. I just want to be sure that it isn't affecting irb when I run it (in particular, the irb in the rbenv-installed Ruby that I normally use), and that future OS X upgrades won't change irb behavior.
/etc/irbrc
doesn't appear to run for me whether or not I have a~/.irbrc
. I'll note that in my question. – Send