bobblez
bobblez

Reputation: 1370

Ruby Gems suddenly stopped working on ubuntu 12.04

After a couple of days of not doing pretty much anything on the ubuntu box, I decided to try out some ruby stuff. For this, I wanted to fire up pry. Unfortunately, I was presented with

Sorry, you can't use Pry without Readline or a compatible library. Please gem install rb-readline or recompile Ruby --with-readline.

~/.rbenv/versions/2.1.1/lib/ruby/2.1.0/rubygems/core_ext/kernel_require.rb:55:in `require': libreadline.so.5: cannot open shared object file: No such file or directory - ~/.rbenv/versions/2.1.1/lib/ruby/2.1.0/x86_64-linux/readline.so (LoadError)

Being quite new to linux in general, I figured I'd just do as it said, and install this rb-readline. The installation passes just fine, but doesnt seem to do anything at all. If I do gem list p, the package just doesn't appear.

So yeah, I just don't know what to do to get it working again, and the only thing I managed to find by searching was related to an installation without rbenv and had something to do with sudo etc.

Any ideas?

Upvotes: 3

Views: 3313

Answers (5)

Hu Willy
Hu Willy

Reputation: 11

I have some problem. But I don't want to add gem 'rb-readline'. So try it...

$ln -s /usr/local/opt/readline/lib/libreadline.8.0.dylib /usr/local/opt/readline/lib/libreadline.7.dylib

Upvotes: 1

joh-mue
joh-mue

Reputation: 1716

I had this problem too. I am using rbenv and reinstalling ruby via

rbenv install -f 2.2.3

did fixed it for me. Of course you'd put in your respective version. -f forces the installation even though you already have that specific version installed. use rbenv global to find out what version you have installed and set.

Upvotes: 8

notapatch
notapatch

Reputation: 7173

Without understanding the problem and following the advice in option 2 of the message:

Sorry, you can't use Pry without Readline or a compatible library.
 Possible solutions:

 * Rebuild Ruby with Readline support using `--with-readline`
 * Use the rb-readline gem, which is a pure-Ruby port of Readline  <==== Option 2
 * Use the pry-coolline gem, a pure-ruby alternative to Readline

I added the gem into the Gemfile (as follows), bundled and pry was then available.

group :development, :test do gem 'pry' gem 'rb-readline' end

Upvotes: 8

bobblez
bobblez

Reputation: 1370

I ended up doing rbenv uninstall, followed by rbenv install and re-installing all the gems, and got it back to working. Still no idea what caused it in the first place, but it works now.

Upvotes: 0

photoionized
photoionized

Reputation: 5232

Do a sudo apt-get install libreadline-dev, seems like you're missing the readline shared library that pry is wanting. If it worked before, not sure why the library isn't there anymore.

Upvotes: 0

Related Questions