byebug: "Sorry, you can't use byebug without Readline"

I started encountering this issue inside a Rails app with byebug 9.0.5 and Ruby 2.2.5. Didn’t change either Rails or Ruby after installing byebug. One day it worked fine, the next I couldn’t boot the Rails app due to this issue. I’m really curious if there’s any other solution than reinstalling that Ruby version.

    Sorry, you can't use byebug without Readline. To solve this, you need to
    rebuild Ruby with Readline support. If using Ubuntu, try `sudo apt-get
    install libreadline-dev` and then reinstall your Ruby.
/Users/olivierlacan/.rbenv/versions/2.2.5/lib/ruby/gems/2.2.0/gems/activesupport-4.2.7.1/lib/active_support/dependencies.rb:274:in `require': dlopen(/Users/olivierlacan/.rbenv/versions/2.2.5/lib/ruby/2.2.0/x86_64-darwin15/readline.bundle, 9): Library not loaded: /usr/local/opt/readline/lib/libreadline.6.dylib (LoadError)
  Referenced from: /Users/olivierlacan/.rbenv/versions/2.2.5/lib/ruby/2.2.0/x86_64-darwin15/readline.bundle
  Reason: image not found - /Users/olivierlacan/.rbenv/versions/2.2.5/lib/ruby/2.2.0/x86_64-darwin15/readline.bundle

It’s honestly a little odd, I don’t remember needing to do anything special with Rubies on prior versions of byebug so I’m thinking this might be less straightforward than it appears perhaps. In any case this issue should help others since I couldn’t find any exact matches on Google for this exact error message.

About this issue

  • Original URL
  • State: closed
  • Created 8 years ago
  • Reactions: 36
  • Comments: 53 (3 by maintainers)

Commits related to this issue

Most upvoted comments

To fix this (for OSX, tested on Sierra), run following command in your shell -

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

@mehta 's command is indeed what fixed the issue for me. Just make sure you’re using it with the right libreadline version in the second part.

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

Someone also suggested adding rb-readline as a development group dependency in the Gemfile: https://twitter.com/ndrx42/status/783288843906801664

same as @coisnepe - had to use 7:

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

@bf4 's solution works for me, thanks @bf4 .

I met this problem after homebrew upgrading the readline from 7.0.5 to 8.0.

> ls -alh /usr/local/opt/readline/lib
total 1448
drwxr-xr-x  11 baurine  staff   352B Dec 20 05:07 .
drwxr-xr-x  12 baurine  staff   384B Jan 17 15:27 ..
-r--r--r--   1 baurine  staff    39K Jan 17 15:27 libhistory.8.0.dylib
lrwxr-xr-x   1 baurine  staff    20B Dec 20 05:07 libhistory.8.dylib -> libhistory.8.0.dylib
-r--r--r--   1 baurine  staff    45K Dec 20 05:07 libhistory.a
lrwxr-xr-x   1 baurine  staff    20B Dec 20 05:07 libhistory.dylib -> libhistory.8.0.dylib
-rw-r--r--   1 baurine  staff   234K Jan 17 15:27 libreadline.8.0.dylib
lrwxr-xr-x   1 baurine  staff    21B Dec 20 05:07 libreadline.8.dylib -> libreadline.8.0.dylib
-r--r--r--   1 baurine  staff   397K Dec 20 05:07 libreadline.a
lrwxr-xr-x   1 baurine  staff    21B Dec 20 05:07 libreadline.dylib -> libreadline.8.0.dylib

> ls -alh /usr/local/Cellar/readline
total 0
drwxr-xr-x   5 baurine  staff   160B Jan 17 15:27 .
drwxrwxr-x  75 baurine  admin   2.3K Jan 17 15:35 ..
drwxr-xr-x  12 baurine  admin   384B Jan 25  2018 7.0.3_1
drwxr-xr-x  12 baurine  staff   384B Sep  6 16:41 7.0.5
drwxr-xr-x  12 baurine  staff   384B Jan 17 15:27 8.0.0

I use brew switch readline 7.0.5 to revert it back and it works back.

> brew switch readline 7.0.5
Cleaning /usr/local/Cellar/readline/8.0.0
Cleaning /usr/local/Cellar/readline/7.0.5
Cleaning /usr/local/Cellar/readline/7.0.3_1
Opt link created for /usr/local/Cellar/readline/7.0.5

Same problem as @baurine in that some library is looking for libreadline.7.dylib even after I upgraded to readline 8. So I used

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

I’m not proud but it works.

I had reinstalled ruby. It have been works well.

Apologies for commenting on an old thread, but if you’re on homebrew, the simplest command is something like brew switch readline 6.3.8 (it’s likely installed in /usr/local/Cellar/readline/ )

If you use rvm you can equally run rvm reinstall <ruby-version> to resolve the readline mismatch.

I was using the gem 'rb-readline' workaround but it stopped working for me yesterday. After some googling I found that a solution is to rebuild ruby on os/x, this way it’s built on the latest libs / header files. This worked for me and seems more like a solution than a work-around.

I wrote up a gist here to give solutions for rvm and rbenv users: https://gist.github.com/soultech67/33ba09706e091c06ce66684cd28015ac

@mehta solution worked for me too.

how @donald-s said you can just reinstall Ruby 👌

rbenv uninstall <ruby-version>
rbenv install <ruby-version>

Apparently this could be due to Homebrew:

@olivierlacan I had this issue on Friday after bumping a bunch of Homebrew libs. Had to recompile Ruby to fix!

@olivierlacan one of these will be the offender - brew uses --installed readline

For me this was the output:

$ brew uses --installed readline
augeas   bash   postgresql   python   sqlite

@mehta answer worked for me too, but had to do a bit change on Linux like below.

sudo ln -s /usr/lib/libreadline.so /usr/lib/libreadline.so.6

@olivierlacan 's post worked for me, thanks so much!

Someone also suggested adding rb-readline as a development group dependency in the Gemfile: https://twitter.com/ndrx42/status/783288843906801664

Also on a side note, loving Ruby Facets man!

Looks like this is related to #118 and could actually be a dupe, please close if that’s the case. It seems like recommending rb-readline as a development dependency tends to lead to issues.

On OSX:

brew list readline

Then look for the installed version of readline’s libreadline.X.X.dylib library. For illustration through example, this is what I saw:

○ → brew list readline
/usr/local/Cellar/readline/8.0.4/include/readline/ (8 files)
/usr/local/Cellar/readline/8.0.4/lib/libhistory.8.0.dylib
/usr/local/Cellar/readline/8.0.4/lib/libreadline.8.0.dylib
/usr/local/Cellar/readline/8.0.4/lib/pkgconfig/readline.pc
/usr/local/Cellar/readline/8.0.4/lib/ (6 other files)
/usr/local/Cellar/readline/8.0.4/share/doc/ (3 files)
/usr/local/Cellar/readline/8.0.4/share/info/ (3 files)
/usr/local/Cellar/readline/8.0.4/share/man/ (2 files)
/usr/local/Cellar/readline/8.0.4/share/readline/ (16 files)

Then just cd into the appropriate directory, here it would be:

cd /usr/local/Cellar/readline/8.0.4/lib/

And then you can create the symlink you need for your missing library. For me, that the original error was Library not loaded: /usr/local/opt/readline/lib/libreadline.7.dylib, so I ran this command:

ln -s libreadline.8.0.dylib libreadline.7.dylib

And like magic - it’s fixed!! Thank you @mehta !!!

@mehta - This solution is absolutely right. All you need is locate libreadline.dylib in your macOS system (I am using macports). Probably libreadline.dylib is symlink to another libreadline library. In my case it is libreadline.8.0.dylib. So in same dir where is this file create symlink: ln -s libreadline.8.0.dylib libreadline.6.dylib

Now byebug starts to work

We tried that for a while but that caused problems for non windows users. I’ll try to migrate to use the brand new pury ruby readline implementation that ruby 2.7 will use by default: reline.

I ran into this issue today and it appears that the problem for me was that a recent update for XCode failed. Reinstalling a fresh version of XCode and then reinstalling the Ruby version worked for me.

Thank you! I just needed to change the symlink to point to 7 instead but it worked after. ln -s libreadline.8.0.dylib libreadline.7.dylib