IRB history not working with Ruby 2.3.0 IRB history not working with Ruby 2.3.0 ruby ruby

IRB history not working with Ruby 2.3.0


OS X's command-line editing is based on the libedit library. OS X has a version of the readline library which is a wrapper around libedit, but it does not behave completely like GNU readline. irb history works in Ruby built with OS X's wrapper up to Ruby 2.1, but Ruby 2.2 and later need to be built with GNU readline for irb history to work.

In the following, 2.3.0 can be any Ruby version from 2.2.0 on. I wrote 2.3.0 since that's what Evan used.

Using Homebrew

If you install ruby using homebrew, it will bring with a working version of readline.

  • brew install ruby

Then follow the instructions to add it to your PATH. Then execute gem install irb if it says can't find gem irb.

Using MacPorts

rbenv doesn't know about MacPorts, so you need to explicitly tell it to use MacPorts' readline.

  • sudo port install readline if it isn't installed already.
  • rbenv uninstall 2.3.0
  • RUBY_CONFIGURE_OPTS=--with-readline-dir=/opt/local rbenv install 2.3.0

Using Homebrew with rbenv

rbenv automatically detects homebrew and looks in it for readline, so, if you're using Homebrew and irb history doesn't work, you either haven't installed readline or you built your Ruby before you installed readline.

  • brew install readline if it isn't installed already
  • rbenv uninstall 2.3.0
  • rbenv install 2.3.0