3 Add Readline support to Ruby on Mac OS X
Cezary Baginski редактировал(а) эту страницу 2015-01-09 06:15:56 +01:00

NOTE: guard-zeus causes issues when typing into the Pry session.

See: https://github.com/guard/guard-zeus/issues/18 for a workaround

Adding Readline support to Pry

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.

Option 1: 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

Option 2: Build Ruby With GNU Readline 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

Option 3: Build Ruby With GNU Readline 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:

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

Option 4: 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.