3
votes

I'm new to ruby on rails. When I use the command: rails console, it comes the problem: "no such file to load -- readline (LoadError)"

   /home/<username>/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/irb/completion.rb:9:in `require': no such file to load -- readline (LoadError)
        from /home/<username>/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/irb/completion.rb:9:in `<top (required)>'
        from /home/<username>/.rvm/gems/ruby-1.9.2-p290/gems/railties-3.2.1/lib/rails/commands/console.rb:3:in `require'
        from /home/<username>/.rvm/gems/ruby-1.9.2-p290/gems/railties-3.2.1/lib/rails/commands/console.rb:3:in `<top (required)>'
        from /home/<username>/.rvm/gems/ruby-1.9.2-p290/gems/railties-3.2.1/lib/rails/commands.rb:38:in `require'
        from /home/<username>/.rvm/gems/ruby-1.9.2-p290/gems/railties-3.2.1/lib/rails/commands.rb:38:in `<top (required)>'
        from script/rails:6:in `require'
        from script/rails:6:in `<main>'

So I searched google, and followed this http://rails3blog.com/2010/09/error-no-such-file-to-load-readline-loaderror/, but it didn't work for me.

My OS is Ubuntu 11.10 with Ruby 1.9.2p290 and Rails 3.2.1

PS: I have install the readline with the command: rvm --skip-autoreconf pkg install readline.

PS:i have solved the problem after a long time search,the answer is under below:

1) ensure you have installed ubuntus readline and editline dev packages

sudo apt-get install libreadline6 libreadline6-dev

2) configure ruby's readline extension to use the systems libs, not rvm's packages

rvm pkg uninstall readline
cd ~/.rvm/src/ruby-1.9.2-p290/ext/readline
ruby extconf.rb --with-editline-dir=/usr/ --with-readline-dir=/usr/
make
make install

3) go to your project and start up the rails console

here is the answer's link : can't get "rails console" to work on ubuntu 11.10

1

1 Answers

1
votes

The above error points to the require 'readline' statement in line 9 of completion.rb

The readline library is not properly installed in your system. You might need to install a libreadline-dev package in ubuntu for it.

Follow this StackOverflow question for ways solve 'no such file to load — readline' error.