Add proper Readline support to Ruby on Mac OS X - jpfuentes2/ender GitHub Wiki

NOTE: This page was stolen copied from the Guard project.

If you are on Mac OS X and have problems with either Guard not reacting to file changes or Pry behaving strangely, then you probably suffer under a Ruby build that uses libedit instead of readline.

If you are not using Mac OS X or are using JRuby, then you're fine.

Build Ruby with GNU readline

Using RVM

You can use RVM to build your Ruby with GNU readline support. First install the readline package with RVM:

$ rvm pkg install readline --verify-downloads 1

Then configure RVM to use the readline package by adding

ruby_configure_flags=--with-readline-dir="$rvm_path/usr"

to ~/.rvm/user/db. Finally you need to reinstall your Ruby of choice:

$ rvm reinstall 1.9.3

Using RVM and Homebrew

You can also install the latest Readline with Homebrew. First install Readline:

$ brew install readline
$ brew link readline

Then configure RVM to use the Homebrew readline by adding

ruby_configure_flags=--with-readline-dir=/usr/local/opt/readline

to ~/.rvm/user/db. Finally you need to reinstall your Ruby of choice:

$ rvm reinstall 1.9.3

Using rbenv, ruby_build and Homebrew

As a rbenv user, you can install readline and ruby_build with Homebrew:

$ brew install readline ruby-build

now set the configure options when compile Ruby:

$ CONFIGURE_OPTS=--with-readline-dir=`brew --prefix readline` rbenv install 1.9.3-p286

Using a pure Ruby readline implementation

The easiest way to get a working readline implementation is to install rb-readline, a pure Ruby readline implementation. You can install it by simply adding

group :development do
  gem 'rb-readline'
end

to your Gemfile and install it with bundle exec.

There have been reported some issues with rb-readline, so you better want to compile your Ruby with real Readline support.