Uncooperative irb on Solaris?
By prashant on Sep 05, 2007
Did you just download Ruby on Solaris and realize that irb is uncooperative with history, tab completion, and line editing?
The problem is that it needs the GNU readline extension. Unlike ssl and curses support, the GNU Readline library is not available on Solaris/OpenSolaris yet.
To enable this support, install GNU Readline, and then build Ruby with the appropriate library/include paths. I've included a list of steps below to save the interested user some time . . .
(1) Download and Install Sun Studio 12. It's pretty easy, pick it up from http://developers.sun.com/sunstudio/downloads/index.jsp. It installs into /opt/SUNWspro
(2) Download the latest stable release of Ruby 1.8.6 from ftp://ftp.ruby-lang.org/pub/ruby/stable-snapshot.tar.gz.
(3) Download GNU Readline from ftp://ftp.cwru.edu/pub/bash/readline-5.2.tar.gz
(4) prefix your path with /opt/SUNWspro/bin. Ensure that /usr/sfw/bin is not in your path for the next step.
(5) run ./configure in, make, and make install
root test4-sp>export PATH="/opt/SUNWspro/bin:/opt/coolstack/bin:/opt/csw/bin:/usr/sbin:/usr/bin"
root test4-sp>./configure --prefix=/export/readline/binaries
[ . . . snip . . .]
[. . .snip . . .]
root test4-sp>make install
Don't get put off by the last message "install: you may need to run ldconfig". ldconfig doesn't exist on Solaris. Use good old crle to add the readline libraries into your path, if you'd like. But it's not necessary for adding readline support to Ruby/irb.
(6) Next, note the path you installed readline into, in my case, it is /export/readline/binaries. We'll have to ensure that the Ruby build knows about this library. So, set your $CFLAGS variable appropriately:
root test4-sp>export CFLAGS="-xO4 -g -L/export/readline/binaries/lib/lib -I/export/readline/binaries/include/readline"
(7) Now, add /usr/local/bin(and /usr/sfw/bin too) to your path for autoconf, and proceed to build Ruby with readline enabled.
./configure --without-gcc --prefix=/export/ruby/builds/ --enable-pthread --with-readline-dir=/export/readline/binaries
(8) then run make, and make install (also make install-doc for ri to work properly).
(9) To turn on tab completion, create a .irbrc file in your home directory which contains the following(courtesy Nick Sieger's blog):
root test4-sp>more ~/.irbrc(10) Now you're set. Emacs style command editing in irb, history, and TAB completion of classes should work like a charm!
ARGV.concat [ "--readline", "--prompt-mode", "simple" ]