Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
377 views
in Technique[技术] by (71.8m points)

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?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...