rails console doesn't load due to libreadline

Solution 1:

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

Solution 2:

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!

Solution 3:

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.

Solution 4:

After getting a lot of positive feedback on my comment on @mauro_oto's post, I thought I'd post this as an answer:

For me cp /usr/local/opt/readline/lib/libreadline.dylib /usr/local/opt/readline/lib/libreadline.6.dylib did the trick. Looks like rails 4.2.6 was looking for libreadline.6 instead of libreadline. I probably should have symlinked it to be honest though. So ln -s /usr/local/opt/readline/lib/libreadline.dylib /usr/local/opt/readline/lib/libreadline.6.dylib is more appropriate. hope this helps others who are still stuck!

Solution 5:

Adding gem 'rb-readline' to my Gemfile fixed this problem for me. See https://github.com/ConnorAtherton/rb-readline.