Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
olivierlacan opened this issue Oct 4, 2016 · 53 comments
Closed

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

olivierlacan opened this issue Oct 4, 2016 · 53 comments

Comments

@olivierlacan
Copy link

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
Copy link
Author

olivierlacan commented Oct 4, 2016

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
Copy link

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
Copy link
Author

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

@olivierlacan
Copy link
Author

@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
Copy link
Author

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
Copy link
Owner

deivid-rodriguez commented Oct 4, 2016

@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
Copy link

kntmrkm commented Oct 5, 2016

I had reinstalled ruby. It have been works well.

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

deivid-rodriguez/byebug#289 (comment)
@deivid-rodriguez
Copy link
Owner

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

misaka added a commit to ministryofjustice/correspondence_tool_public that referenced this issue Dec 1, 2016
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.
@mehta
Copy link

mehta commented Dec 6, 2016

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

@kirillshevch
Copy link

@mehta thanks!

@parkerholcomb
Copy link

@mehta bloody perfect!

@hraynaud
Copy link

@mehta solution worked for me too.

@jasonfagan
Copy link

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

@iqbalhasnan
Copy link

Thanks @mehta

@ghost
Copy link

ghost commented Jan 8, 2017

@mehta worked for me, thanks.

@Schwad
Copy link

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
Copy link

Worked for me in El Capitan as well.

@bhoormeena
Copy link

@mehta thanks buddy!

@dgnv
Copy link

dgnv commented Mar 1, 2017

@mehta 👍

@pinkopaque22
Copy link

Thanks man! That did the trick. SO grateful.

@ragavendra
Copy link

@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

@danmoore2205
Copy link

thanks @mehta saved me!

@soultech67
Copy link

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

@neohunter
Copy link

Worked also on el capitan.

@Iqlaas
Copy link

Iqlaas commented Jun 19, 2017

@mehta still works mate. cheers.

@txssseal
Copy link

@mehta gracias senor

@baird
Copy link

baird commented Jun 28, 2017

@mehta my dude

@pragmat1c1
Copy link

@mehta Dankeschoen! Excellent!

nicolasrouanne added a commit to nicolasrouanne/rails-templates that referenced this issue Jul 17, 2017
… installation

- when installing (on Mac OS Sierra for instance), `byebug` generated an error since it required `readline` which wasn't installed
- see `byebug` related issue
@link deivid-rodriguez/byebug#289
@bf4
Copy link

bf4 commented Jan 30, 2018

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/ )

@wayne-crs
Copy link

@mehta Cheers. Worked for me on High Sierra

@yogeshmurugesan
Copy link

@mehta worked for me.

@coisnepe
Copy link

coisnepe commented Jan 14, 2019

@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

@baurine
Copy link

baurine commented Jan 21, 2019

@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

@LarryWachira
Copy link

LarryWachira commented Jan 23, 2019

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

@skbailey
Copy link

@mehta the real MVP, this worked for me

@itcentralstation
Copy link

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.

@pranav-bagree
Copy link

@itcentralstation this worked for me! Thanks 👍

@davidcpell
Copy link

davidcpell commented Jan 31, 2019

same as @coisnepe - had to use 7:

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

@srikirancse
Copy link

@mehta Man of the hour!

@storrence88
Copy link

@itcentralstation This worked for me! Thanks!

@jamsi
Copy link

jamsi commented Mar 25, 2019

@davidcpell thanks mate, worked well :D

@masak2009
Copy link

@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

@sarsena
Copy link

sarsena commented Jul 3, 2019

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

@mothule
Copy link

mothule commented Jul 23, 2019

I changed the version with brew switch and solved it, because it's on Mac.

like it $ brew switch readline 7.0.3_1.

@masak2009
Copy link

@mothule - On mac you should use brew or macports. The key is in "missing file" or "missing link" which solve at general the problem.

@theotherdon
Copy link

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.

@stdedos
Copy link

stdedos commented Sep 9, 2019

Originally posted by @Schwad in #289 (comment)

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

Would it make sense to add it as a dependency of byebug @deivid-rodriguez?

@deivid-rodriguez
Copy link
Owner

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.

@lavaldi
Copy link

lavaldi commented Sep 27, 2019

how @DoNalD-S said you can just reinstall Ruby 👌

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

@Oceantidote
Copy link

@mehta you legend 🙏

@MFRWDesign
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests