Fixing irb readline support in ruby 1.8.x with OS X and the Hivelogic install

I installed a “working” ruby the Hivelogic way the other day. er, night… I didn’t have time to do any testing before going to bed, and like lots of adventurous fools, I didn’t make any notes. Unfortunately, I sat down with it today [finally] and discovered that readline still doesn’t work with irb! Oh well, just do it again, thunk I, but enough googling yields results, man! (for those who don’t know, irb is the unix tool that lets you cycle through previous command line typings by using the up-arrrow and down-arrow keys. If it isn’t working with a particular command line tool, you will know right away when you try to use it, because you’ll get garbled junk instead of what you expect.)

So the Hivelogic Ruby and Rails stuff installs to:
/usr/local/lib
This is where the problem may lie. It may have to do with the install scripts or the fact that you install Ruby before readline… anyway, Ruby gets installed not linked to readline. You get no warning. Ruby does not by default issue warnings for all missing things and just compiles with everything you ask for, broken dependencies or not. Not my department, so I’m not complaining!

So, to fix this puppy, open the rbconfig.rb file in TextMate (or your editor of choice).
This file should be at the following path (or some variation of the number after powerpc-darwin…, if you’re on a MacIntel, the path should be similar):
/usr/local/lib/ruby/1.8/powerpc-darwin8.3.0/rbconfig.rb
In your editor, do a search for the exact string:
CONFIG["LIBS"]
Select the whole line, copy, paste a copy and comment it out with # as a backup, in case it doesn’t work for you.
At the end of the line, there is a set of flags in quotes, add
-lreadline to the end of CONFIG["LIBS"] line, inside the closing quote.
Save. Go back to Terminal and test your newly working readline function in irb.

*-attribution for this solution goes to Jim Menard, http://www.io.com/~jimm

His orginal was posted at http://www.nabble.com/Ruby-1.8.4-Mac-OS-X-readline-problems-t801880.html

0 comments ↓

There are no comments yet...Kick things off by filling out the form below.

Leave a Comment