"Sorry, you can't use byebug without Readline" #289

Closed
olivierlacan opened this Issue Oct 4, 2016 · 18 comments

Projects

None yet
@olivierlacan

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.

@olivierlacan
olivierlacan commented Oct 4, 2016 edited

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
@chattsm
chattsm commented Oct 4, 2016

Hi @olivierlacan, what is your output from brew info readline?

Mine is...

$ brew info readline
readline: stable 7.0 (bottled) [keg-only]
Library for command-line editing
https://tiswww.case.edu/php/chet/readline/rltop.html
/usr/local/Cellar/readline/7.0 (45 files, 2M)
  Poured from bottle on 2016-09-30 at 11:07:04
From: https://github.com/Homebrew/homebrew-core/blob/master/Formula/readline.rb

My Ruby (managed by ruby-install / chruby) broke after 2016-09-30 at 11:07:04, which is when I updated a bunch of my Homebrew installs and ran a brew cleanup (thus removing readline v6.0).

$ ls -l /usr/local/opt/readline/lib
total 2744
-r--r--r--  1 chattsm  admin   84728 30 Sep 11:07 libhistory.7.0.dylib
lrwxr-xr-x  1 chattsm  admin      20  7 Sep 22:16 libhistory.7.dylib -> libhistory.7.0.dylib
-r--r--r--  1 chattsm  admin   84480  7 Sep 22:16 libhistory.a
lrwxr-xr-x  1 chattsm  admin      20  7 Sep 22:16 libhistory.dylib -> libhistory.7.0.dylib
-r--r--r--  1 chattsm  admin  459608 30 Sep 11:07 libreadline.7.0.dylib
lrwxr-xr-x  1 chattsm  admin      21  7 Sep 22:16 libreadline.7.dylib -> libreadline.7.0.dylib
-r--r--r--  1 chattsm  admin  751528  7 Sep 22:16 libreadline.a
lrwxr-xr-x  1 chattsm  admin      21  7 Sep 22:16 libreadline.dylib -> libreadline.7.0.dylib

I had to re-compile Ruby to fix this issue. Interesting to know if there is a better/simpler fix for it!

@olivierlacan

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

@olivierlacan

@chattsm

$ brew info readline
readline: stable 7.0 (bottled) [keg-only]
Library for command-line editing
https://tiswww.case.edu/php/chet/readline/rltop.html
/usr/local/Cellar/readline/6.3.8 (46 files, 2.0M)
  Poured from bottle on 2015-09-11 at 16:22:41
/usr/local/Cellar/readline/7.0 (45 files, 2M)
  Poured from bottle on 2016-10-03 at 18:43:51
From: https://github.com/Homebrew/homebrew-core/blob/master/Formula/readline.rb
==> Caveats
This formula is keg-only, which means it was not symlinked into /usr/local.

OS X provides the BSD libedit library, which shadows libreadline.
In order to prevent conflicts when programs look for libreadline we are
defaulting this GNU Readline installation to keg-only.


Generally there are no consequences of this for you. If you build your
own software and it requires this formula, you'll need to add to your
build variables:

    LDFLAGS:  -L/usr/local/opt/readline/lib
    CPPFLAGS: -I/usr/local/opt/readline/include
@olivierlacan

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.

@deivid-rodriguez
Owner
deivid-rodriguez commented Oct 4, 2016 edited

@olivierlacan Did you try reinstalling your Ruby after sorting out your readline libraries? I'm not aware of a better solution...

By the way, anyone contributing to the discussion here, feel free to improve the troubleshooting instructions for OSX. I don't use that, so I have no idea. Or maybe a wiki page should be created and linked from the error message, I don't know.

@kntmrkm
kntmrkm commented Oct 5, 2016

I had reinstalled ruby. It have been works well.

@adarsh adarsh added a commit to gabebw/youshouldtotally that referenced this issue Oct 7, 2016
@adarsh adarsh Update Ruby Version to 2.3.1
Minor
=====
* Had to add `rb-readline` gem for this Ruby to work correctly.

deivid-rodriguez/byebug#289 (comment)
d0dec30
@adarsh adarsh referenced this issue in gabebw/youshouldtotally Oct 7, 2016
Merged

Update Ruby Version to 2.3.1 #20

@deivid-rodriguez
Owner

I'm going to close this since it does not seem like a problem in byebug.

@raq929 raq929 referenced this issue in ga-wdi-boston/ruby-template Oct 31, 2016
Open

Brew Upgrade Updates Readline Breaking pry #9

@misaka misaka added a commit to ministryofjustice/correspondence_tool_public that referenced this issue Dec 1, 2016
@misaka misaka Fix byebug error
Not certain why but in certain circumstances ruby seems to lose it's
link to the readline dylib causing byebug to raise errors when being
required, possibly as a result of a 'brew update'. The fix in this
commit is mentioned here:

deivid-rodriguez/byebug#289

The alternative seems to be to recompile ruby.
2c8a498
@misaka misaka referenced this issue in ministryofjustice/correspondence_tool_public Dec 1, 2016
Merged

Fix byebug error #97

@mehta
mehta commented Dec 6, 2016 edited

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

@kirillweb

@mehta thanks!

@parquar
parquar commented Dec 8, 2016

@mehta bloody perfect!

@misaka misaka added a commit to ministryofjustice/correspondence_tool_staff that referenced this issue Dec 8, 2016
@misaka misaka Fix byebug error
Not certain why but in certain circumstances ruby seems to lose it's
link to the readline dylib causing byebug to raise errors when being
required, possibly as a result of a 'brew update'. The fix in this
commit is mentioned here:

deivid-rodriguez/byebug#289

The alternative seems to be to recompile ruby.
485c075
@misaka misaka referenced this issue in ministryofjustice/correspondence_tool_staff Dec 8, 2016
Merged

Fix byebug error #50

@misaka misaka added a commit to ministryofjustice/correspondence_tool_staff that referenced this issue Dec 9, 2016
@misaka misaka Fix byebug error (#50)
Not certain why but in certain circumstances ruby seems to lose it's
link to the readline dylib causing byebug to raise errors when being
required, possibly as a result of a 'brew update'. The fix in this
commit is mentioned here:

deivid-rodriguez/byebug#289

The alternative seems to be to recompile ruby.
4bf46dc
@hraynaud

@mehta solution worked for me too.

@jasonfagan

@mehta definite fix for Sierra, no reinstall or recompile of Ruby needed. Thanks a lot for this tip!!

@iqbalhasnan

Thanks @mehta

@dimosz
dimosz commented Jan 8, 2017

@mehta worked for me, thanks.

@Schwad
Schwad commented Jan 8, 2017

@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!

@wflanagan

Worked for me in El Capitan as well.

@bhoormeena

@mehta thanks buddy!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment