Rails console: in `require': cannot load such file -- readline (LoadError)

Flock Dawson picture Flock Dawson · Apr 7, 2014 · Viewed 19.9k times · Source

I've got some errors in my Rails app and I'm trying to start the Rails console by issuing following command:

rails console

No matter what I try, I'm always getting the same error:

/usr/local/rvm/rubies/ruby-2.1.1/lib/ruby/2.1.0/irb/completion.rb:9:in `require': cannot load such file -- readline (LoadError)
    from /usr/local/rvm/rubies/ruby-2.1.1/lib/ruby/2.1.0/irb/completion.rb:9:in `<top (required)>'
    from /opt/mammie/web/icosole/vendor/bundle/ruby/2.1.0/gems/railties-3.1.3/lib/rails/commands/console.rb:3:in `require'
    from /opt/mammie/web/icosole/vendor/bundle/ruby/2.1.0/gems/railties-3.1.3/lib/rails/commands/console.rb:3:in `<top (required)>'
    from /opt/mammie/web/icosole/vendor/bundle/ruby/2.1.0/gems/railties-3.1.3/lib/rails/commands.rb:37:in `require'
    from /opt/mammie/web/icosole/vendor/bundle/ruby/2.1.0/gems/railties-3.1.3/lib/rails/commands.rb:37:in `<top (required)>'
    from script/rails:6:in `require'
    from script/rails:6:in `<main>'

I've really tried every possible solution I found on the net, as many people encounter the same error. Unfortunately, nothing seems to work. When I try the following command:

ruby /usr/local/rvm/src/ruby-2.1.1/ext/readline/extconf.rb

I get following output

checking for tgetnum() in -lncurses... yes
checking for readline/readline.h... yes
checking for readline/history.h... yes
checking for readline() in -lreadline... no
checking for readline() in -ledit... no
checking for editline/readline.h... no
*** /usr/local/rvm/src/ruby-2.1.1/ext/readline/extconf.rb failed ***

Indicating that something is missing, but installing readline with apt-get doesn't make a difference either. I'm guessing it could have something to do with incompatible gem versions, as the console worked briefly some time ago. Are there any known version issues with readline? Very much people seem to have encountered problems with this gem.

Answer

hunterboerner picture hunterboerner · Apr 7, 2014

Try putting rb-readline in your Gemfile and check this out https://stackoverflow.com/a/9595841/1905235