Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 321
gkaykck Avatar asked Feb 07 '11 14:02

gkaykck


2 Answers

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 
like image 124
winfred Avatar answered Sep 29 '22 03:09

winfred


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/

like image 38
Nikolay Moskvin Avatar answered Sep 29 '22 01:09

Nikolay Moskvin