Blog

Jan
09
Fixing Ruby no such file to load readline error in centOS
by Alex Chee | Snippet

If you're new here, you may want to subscribe to our RSS feed. Thanks for visiting!

Does this error message look familar when you script/console?


$> script/console
Loading production environment (Rails 2.1.0)
/usr/lib/ruby/1.8/irb/completion.rb:10:in `require': no such file to load -- readline (LoadError)
from /usr/lib/ruby/1.8/irb/completion.rb:10
from /usr/lib/ruby/1.8/irb/init.rb:252:in `require'
from /usr/lib/ruby/1.8/irb/init.rb:252:in `load_modules'
from /usr/lib/ruby/1.8/irb/init.rb:250:in `each'
from /usr/lib/ruby/1.8/irb/init.rb:250:in `load_modules'
from /usr/lib/ruby/1.8/irb/init.rb:21:in `setup'
from /usr/lib/ruby/1.8/irb.rb:54:in `start'
from /usr/bin/irb:13

This happens when readline is somehow different than your current version of ruby or corrupted. The quick fix is to recompile readline. To do it in CentOS with yum:


$> yum install readline-devel -y
$> cd /root/src/ruby-1.8.6-p114/ext/readline/
$> ruby extconf.rb
$> make
$> sudo make install

Now you should have script/console working.

6 Comments
March 14, 2009

Thanks for your post! I ran into this exact problem yesterday trying to get Ruby 1.8.7 working on CentOS5, and your solution worked great.

Fawad
April 10, 2009

Thanks, this really helps me a lot.

August 11, 2009

extconf.rb wasn’t where I expected it. Anyone who has gotten this far probably knows to type `locate extconf.rb | grep readline` or something like that, but just in case…

November 24, 2009

i had to yum install ncurses-devel as well to get readline to compile…

March 7, 2010

I was also missing readline support in my Ruby installation, which rvm built for me. I went to ~/.rvm/src/ruby-1.8.7-p249/ext/readline, ran ‘make distclean’, then ‘ruby extconf.rb’ and got an error. Looking at mkmf.log, I found I needed to install a libreadline-dev. Since I’m on Ubuntu, not CentOS, I installed with ‘sudo apt-get install libreadline6-dev’. Then, ‘make’ and ‘make install’ worked perfectly (installed readline.so in ~/.rvm/rubies/ruby-1.8.7-p249/lib) and ‘require “readline”‘ in irb now works and I can start my Rails app with ‘script/server –debug’. I’m with Rails 2.3.5.

MadsBuus
June 2, 2010

Thanks, just what needed to be done in my case too. Worked for 1.8.7.