Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

rails console doesn't load due to libreadline

I have recently reinstalled ruby 2.1.2 like so since I wanted to install a gem (ruby-debug-ide)

sudo rvm reinstall 2.1.2 --disable-binary --with-gcc=gcc-4.2

Since then, I can't load my console using bundle exec rails c due to the following error :

/Users/ohad/.rvm/gems/ruby-2.1.2@aaa/gems/activesupport-3.2.11/lib/active_support/dependencies.rb:251:in `require': dlopen(/Users/ohad/.rvm/rubies/ruby-2.1.2/lib/ruby/2.1.0/x86_64-darwin13.0/readline.bundle, 9): Library not loaded: @@HOMEBREW_PREFIX@@/opt/readline/lib/libreadline.6.dylib (LoadError)
  Referenced from: /Users/ohad/.rvm/rubies/ruby-2.1.2/lib/ruby/2.1.0/x86_64-darwin13.0/readline.bundle

Tried brew uninstall readline and brew install --build-from-source readline which worked but didn't solve my problem.

like image 998
WebQube Avatar asked Aug 31 '14 11:08

WebQube


3 Answers

Ran across this today, to solve it I did:

brew rm -f readline

brew install readline

brew link readline --force

Hope it helps.

EDIT: I recently ran into this problem again (after downgrading Ruby) since I wrote this, and I now prefer @califrench's solution from the comments below:

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

like image 184
mauro_oto Avatar answered Oct 27 '22 11:10

mauro_oto


Based on a comment on the accepted answer with more up-votes than the answer, this seems to be the most popular solution.

Looks like rails 4.2.6 was looking for libreadline.6 instead of libreadline. So just need to create a symlink.

ln -s /usr/local/opt/readline/lib/libreadline.dylib \
/usr/local/opt/readline/lib/libreadline.6.dylib 

Hope this helps others who are still stuck!

like image 29
2 revs, 2 users 75% Avatar answered Oct 27 '22 11:10

2 revs, 2 users 75%


I was able to resolve the same problem by reinstalling Ruby. On the Homebrew side reinstalling readline (even from source) didn't help.

I'm using RVM so this sorted it for me:

rvm reinstall 2.3.1

I think Homebrew may have pulled in readline v7 recently for some other package, which I suspect could well be the culprit.

like image 52
paws Avatar answered Oct 27 '22 11:10

paws