no such file to load — readline (LoadError) when running script/console

Ruby on Rails, Ubuntu/Linux Add comments

If you get

Loading development environment (Rails 2.3.2)
/usr/local/lib/ruby/1.8/irb/completion.rb:10:in `require’: no such file to load — readline (LoadError)
        from /usr/local/lib/ruby/1.8/irb/completion.rb:10
        from /usr/local/lib/ruby/1.8/irb/init.rb:252:in `require’
        from /usr/local/lib/ruby/1.8/irb/init.rb:252:in `load_modules’
        from /usr/local/lib/ruby/1.8/irb/init.rb:250:in `each’
        from /usr/local/lib/ruby/1.8/irb/init.rb:250:in `load_modules’
        from /usr/local/lib/ruby/1.8/irb/init.rb:21:in `setup’
        from /usr/local/lib/ruby/1.8/irb.rb:54:in `start’
        from /usr/local/bin/irb:13

when running script/console, you might be missing some libraries after you’ve installed Ruby from source. So you might try (Ubuntu, Debian):

sudo apt-get install libncurses5-dev

sudo apt-get install libreadline5-dev

Then cd to the folder with your unpacked Ruby sources, subfolder ext/readline:

cd /usr/src/ruby-1.8.7-p72/ext/readline

ruby extconf.rb

make

sudo make install

There is no need to recompile Ruby. If you get any of these:

checking for tgetnum() in -lncurses… no
checking for tgetnum() in -ltermcap… no
checking for tgetnum() in -lcurses… no
checking for readline/readline.h… no
checking for editline/readline.h… no

you’re still missing libraries so re-check if the apt-get commands above completed without errors. Hope it helps.

[Slashdot] [Digg] [Reddit] [del.icio.us] [Facebook] [Technorati] [Google] [StumbleUpon]

20 Responses to “no such file to load — readline (LoadError) when running script/console”

  1. 'no such file to load -- readline' error with Rails script/console at Supersonic Feet Says:

    [...] a good how-to at dirk.net (it’s really simple), but if like me you’re using CentOS rather than some version of Debian, then [...]

  2. Christian Says:

    Thank you for the hint! Worked fine with my self compiled rails on Debian Lenny.

  3. Brock Says:

    It’s all fun and games until someone compiles from source. Thank you for the tip!

  4. Lucas Says:

    Thank you it worked !!

  5. Shih-gian Lee Says:

    Thank you, sir. Worked like a charm!

  6. daniel spaniel Says:

    Thanks a tonnage. Finally found your solution which worked!

  7. Ralf Says:

    Thank you very much. Worked nicely.

  8. kongkoro Says:

    Worked for me thanks!!!

  9. dave Says:

    thanks for the secret knowlege! helped a lot.

    centOS people – it’s a lil different, read this article
    http://blog.elctech.com/2009/01/09/fixing-ruby-no-such-file-to-load-readline-error-in-centos/

  10. bainur Says:

    thank u, work like a magic :D

  11. Denis Says:

    Thanks a lot!

  12. roger Says:

    Thanks for the tip. Barring this, you can also install the “pure ruby readline”

  13. Debian下安装Heroku开发环境 | mylxiaoyi@wordpress Says:

    [...] 安装之后我们就可以使用heroku命令来创建我们的第一个Heroku程序了。如果出现require错误,则可以参考这里解决。 [...]

  14. magesh Says:

    That helped! thanks a lot

  15. Hari Says:

    Thank you!!!

  16. Pato Says:

    Thank you!!!

  17. shir Says:

    Thanks!

  18. Gaziz T Says:

    Thanks! That did help me!

  19. Rafael Says:

    Thanks!! That caused me problems to install ripl. Thanks again!

  20. Beginner Rails: Heroku | Jeff Barr - Horror/SciFi/Fantasy Pulp Fiction Writer, Coder, Hacker, Musician Says:

    [...] to dirk.net, this error is due to missing libraries after installing ruby from [...]

Leave a Reply