Ruby 1.9.2 and Rails 3 cannot open rails console
[gkaykck@main myApplication]$ rails console
/usr/local/lib/ruby/1.9.1/irb/completion.rb:9:in `require': no such file to load -- readline (LoadError)
from /usr/local/lib/ruby/1.9.1/irb/completion.rb:9:in `<top (required)>'
from /usr/local/lib/ruby/gems/1.9.1/gems/railties-3.0.3/lib/rails/commands/console.rb:3:in `require'
from /usr/local/lib/ruby/gems/1.9.1/gems/railties-3.0.3/lib/rails/commands/console.rb:3:in `<top (required)>'
from /usr/local/lib/ruby/gems/1.9.1/gems/railties-3.0.3/lib/rails/commands.rb:20:in `require'
from /usr/local/lib/ruby/gems/1.9.1/gems/railties-3.0.3/lib/rails/commands.rb:20:in `<top (required)>'
from script/rails:6:in `require'
from script/rails:6:in `<main>'
I have installed rails 3 on ruby 1.9.2p136, which is ok i guess. But i cannot start rails console and it gives me the error i copied. The apps worked great with ruby 1.8.7 and i never saw an error like this.
Any ideas what it could be?
Solution 1:
Apparently ubuntu and ruby don't always catch dependencies like they should.
From the first google hit (yeah, I clicked on this stack-overflow in place #2 before checking out the first result.)
Navigate to the Ruby source and enter:
sudo apt-get install libreadline5-dev
cd ext/readline
ruby extconf.rb
make
sudo make install
So, if you're on another distro, make sure you install readline somehow (source/package), then run make/install on extconf from the source. I tried what gkaykck suggested of course but got this without readline already on my system.
$ ruby extconf.rb
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
Solution 2:
Recipe for those who use rvm:
rvm pkg install readline
rvm remove 1.9.3
rvm install 1.9.3 --with-readline-dir=$rvm_path/usr
In more details about it on https://rvm.io/packages/readline/