18

Possible Duplicate:
Ruby 1.9.2 and Rails 3 cannot open rails console

I have already installed rvm and ruby 1.9.2, both working properly. Using rvm version 1.10.2. I previously installed the rvm packages readline/zlib, but now I'm having big troubles with readline now. I'm trying to install ruby 1.9.3 in rvm, but I always end up having readline not found.

I tried to follow different solutions:

 rvm remove 1.9.3
 rvm pkg install readline
 rvm install 1.9.3 --with-readline-dir=$rvm_path/usr/ \
     --with-zlib-dir=$rvm_path/usr/

 rvm use 1.9.3
 rvmsudo gem install bundler
 bundle install (all gems installed fine)
 rails c / rails s 
 .rvm/rubies/ruby-1.9.3-p0/lib/ruby/1.9.1/irb/completion.rb:9:in `require': \
     cannot load such file -- readline (LoadError)

I have libreadline-dev (version 6, the current one) installed (everything needed by those packages pretty much)

I also tried the following:

.rvm/src/ruby-1.9.3-p0/ext/readline]$ ruby extconf.rb 
 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

.rvm/src/ruby-1.9.3-p0/ext/readline]$ ruby extconf.rb \
    --with-readline-dir=/home/claudiocontin/.rvm/usr/
 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

 .rvm/src/ruby-1.9.3-p0/ext/readline]$ ruby extconf.rb \
    --with-readline-lib=/home/claudiocontin/.rvm/usr/
 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

Makefile is not generated of course ...

 apt-get install libreadline-dev
 Reading package lists... Done
 Building dependency tree       
 Reading state information... Done
 libreadline-dev is already the newest version.

Ideas?

Community
  • 1
  • 1
CLod
  • 917
  • 2
  • 11
  • 28

3 Answers3

46

I tried to do rvm pkg readline, install ubuntu pkgs etc without any success. What worked for me:

gem install rb-readline

And add the following line to your Gemfile:

gem 'rb-readline'
Philippe Creux
  • 1,436
  • 1
  • 11
  • 9
  • Thanks a lot! I tried EVERY solution here and EVERY solution in rvm page with no luck. Been trying to get this working for hours now! This worked nicely. Thanks again! – AyJay Apr 26 '12 at 18:58
  • +1 Very good alternative to building readline. I've installed hundreds of libraries from source before, but couldn't get the readline extension to build on a certain machine. – Kelvin May 23 '12 at 18:20
  • Excellent Fix.. Hats of to the guy who bundled it to a Gem. I am interested to know more about it. – Krishna Prasad Varma Jan 29 '13 at 11:44
12

What I ended up doing is remove all the libreadline from rvm usr/lib/ path.

Installed libreadline5-dev package (.deb in this case) downloaded manually, because the new ubuntu distro has only libreadline6-dev as candidate.

went to rvm ruby 1.9.3 src and:

ruby extconf.rb --with-editline-dir=/usr/ --with-readline-dir=/usr/
make
sudo make install

Now works like a charm.

Very painful stuff :)

edit:

also keep in mind that readline uses also libeditline-dev now, you can disable manually when configure ruby readline , passing: --disable-libedit

 ruby extconf --disable-libedit
CLod
  • 917
  • 2
  • 11
  • 28
5

I've always found getting RVM to play nicely with packages to be a bit of voodoo. A lot of times, it's about catching a dependency - I put together a script that I've had luck with in past, try this:

sudo apt-get install zlib1g-dev libssl-dev libsqlite3-dev libmysqlclient-dev imagemagick librmagick-ruby libxml2-dev libxslt1-dev build-essential openssl libreadline6 libreadline6-dev zlib1g libyaml-dev libsqlite3-0 sqlite3 libxml2-dev libxslt-dev autoconf libc6-dev ncurses-dev automake libtool bison libpq-dev libpq5 libmysql-ruby libmysqlclient-dev

rvm pkg install autoconf
rvm pkg install zlib
rvm pkg install readline
rvm pkg install openssl
rvm pkg install iconv
rvm install 1.9.3
rvm use 1.9.3 --default
Mark Tabler
  • 1,421
  • 10
  • 16