Fixing Symbol not found _rl_filename_completion_function

November 06, 2008

Not a full article this time but rather a tip that will help poor souls looking for their salvation on Google.

Some context: I was working on a Merb + CouchDB application. While installing a dependency with Thor, I got the following error:

$ thor merb:gem:install dm-more
dyld: NSLinkModule() error
dyld: Symbol not found: _rl_filename_completion_function
  Referenced from: /usr/local/lib/ruby/1.8/i686-darwin9.5.0/readline.bundle
  Expected in: flat namespace

Trace/BPT trap

I had recompiled a version of Ruby (switching from 1.8.6 patchlevel 0 to patchlevel 111) and got this error a few days later.

“rl” and “readline” give us clues about what’s happening. The fix is to recompile the readline extension from the Ruby source:

cd /usr/local/src/ruby-1.8.6-p111/ext/readline
ruby extconf.rb
make clean
make
sudo make install

This reinstalls the readline bundle:

/usr/bin/install -c -m 0755 readline.bundle \
  /usr/local/lib/ruby/site_ruby/1.8/i686-darwin9.5.0

Then back to Thor, everything was back to normal:

$ thor merb:gem:install dm-more
Installing dm-more...
Successfully installed dm-couchdb-adapter-0.9.6
Successfully installed dm-rest-adapter-0.9.6

Full credit goes to Matthew Hutchinson who originally posted this fix.