Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
ruby bundler: Sorry, you can't use byebug without Readline

Preamble

On OS/X Sierra, after recently running a brew update I started receiving the error message Sorry, you can't use byebug without Readline when trying to run some rake tasks in my ruby project folder. I observed this in projects and gems that include byebug or pry in their Gemfile or gem.spec. I've found in my googling that many begin encountering this error message after running a brew update but there are other triggering conditions as well.

>> rake aws:show_config
WARN: Unresolved specs during Gem::Specification.reset:
      mime-types (>= 0)
WARN: Clearing out unresolved specs.
Please report a bug if this causes problems.
    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.
rake aborted!

OS/X uses editline or libedit instead of readline. To fix this issue we'll rebuild ruby against the latest OS/X libs. You may need to install readline support on OS/X after the OS/X update. Turned out for me that I had it, I just needed to recompile ruby.

One solution

I use rvm to manage my ruby versions. You can use rvm to recompile ruby from source to solve the problem. There are a few other work arounds as well, but this seemed like the correct solution and it worked for me.

Sounds like we should generally rebuild ruby as a best practice after os/x upgrades. In this case it was os/x Sierra + brew updates that triggered this new awareness for me.

Steps to rebuild ruby via rvm

It's a good idea to make sure you've installed the latest Xcode + tools before proceeding; check App Store for updates. Be sure to accept the Xcode License before proceeding!

Update Xcode and accept the license:

  • Update Xcode to latest via App Store, be sure to update the Xcode Tools as well.
  • In a terminal window, exec this command: sudo xcodebuild -license accept

Make sure you have the readline lib installed:

  • brew --prefix readline
  • if you get Error: No available formula with the name "readline", install readline:
    • brew install readline
    • brew link --force readline
    • vi ~/.rvm/user/db and add the following: ruby_configure_flags=--with-readline-dir=/usr/local/opt/readline

Reinstall Ruby, with a rebuild of sources:

  • rvm reinstall 2.3.1 This command removes the specified version's ruby binaries and libs, and rebuilds from source code on your system, with the latest os/x headers and libs.
  • rvm reinstall 2.3.1 --gems This command repro's the same steps as above, but it removes the gems first as well. The next time you run bundle install the gems will be downloaded and rebuilt against your latest ruby. This can help resolve other potential issues with gems after rebuilding ruby on os/x.
  • change the specified version (2.3.1 in my case) to match your needs

I ended up using the second syntax for a completely fresh start.

After completing these steps I did two more things:

  • Since I happened to be in a project directory in a terminal window when I started this process, I cd .. up a level and then cd project-folder back into my project so that rvm would reactivate my gemset.
  • I ran gem install bundler and then bundle install to re-hydrate the gems for my project.
  • and then I was off to the races again.

Steps to fix this via rbenv

We don't use rbenv at our shop, but I wanted to include this for compeleteness. Jump over to the excellent write-up here, which specifically deals with the missing readline issue: http://albertogrespan.com/blog/installing-ruby-the-right-way-on-os-x-using-rbenv/

  • brew install readline ruby-build
  • RUBY_CONFIGURE_OPTS=--with-readline-dir=`brew --prefix readline` rbenv install 2.3.1
  • change the specified version (2.3.1 in my case) to match your needs

Follow up

If this still doesn't solve the problem for you, there may be some missing libs or more specific bindings you need to coerce. Read this more detailed write-up with additional rebuild specificity here: https://github.com/guard/guard/wiki/Add-Readline-support-to-Ruby-on-Mac-OS-X

More info:

@MelissaKaulfuss

This comment has been minimized.

Copy link

@MelissaKaulfuss MelissaKaulfuss commented Nov 8, 2017

Thanks heaps for this gist \o/
Just ran into this very issue and it was baffling. Your solution for rbenv worked a treat!

@tosbourn

This comment has been minimized.

Copy link

@tosbourn tosbourn commented Jan 11, 2018

Just wanted to say I really appreciate you taking the time to share this. Saved me some head scratching.

@Mihoid

This comment has been minimized.

Copy link

@Mihoid Mihoid commented Apr 21, 2018

rbenv solution works for me. thanks!

@grillermo

This comment has been minimized.

Copy link

@grillermo grillermo commented Jan 24, 2019

Thank you, you da mvp

@fdominguezclaro

This comment has been minimized.

Copy link

@fdominguezclaro fdominguezclaro commented Mar 12, 2019

Thanks! Works great with rbenv.

@ritec

This comment has been minimized.

Copy link

@ritec ritec commented Mar 21, 2019

Thanks for this writeup good sir.

@sharkeyryan

This comment has been minimized.

Copy link

@sharkeyryan sharkeyryan commented Mar 26, 2019

This worked for me under rbenv installing 2.6.1.

Thanks!

@DanteCavero

This comment has been minimized.

Copy link

@DanteCavero DanteCavero commented May 23, 2019

Thank you for this!!! You made my day!

@Willdta

This comment has been minimized.

Copy link

@Willdta Willdta commented Jun 4, 2019

Thank you!

@chrisZingel

This comment has been minimized.

Copy link

@chrisZingel chrisZingel commented Jun 4, 2019

Thank you. Works great with rbenv

@bricemaurin

This comment has been minimized.

Copy link

@bricemaurin bricemaurin commented Jun 15, 2019

This worked for me using rbenv, thanks !

@yuto2121

This comment has been minimized.

Copy link

@yuto2121 yuto2121 commented Jul 1, 2019

Thank you for your sharing! It works well for me.

@Yorkshireman

This comment has been minimized.

Copy link

@Yorkshireman Yorkshireman commented Jul 4, 2019

👍

@MatthewTFarley

This comment has been minimized.

Copy link

@MatthewTFarley MatthewTFarley commented Aug 6, 2019

rbenv solution just works. Thank you! 👍

@LilyMarcela

This comment has been minimized.

Copy link

@LilyMarcela LilyMarcela commented Oct 4, 2019

rbenv solution works perfectly, thank you 👍

@zaimramlan

This comment has been minimized.

Copy link

@zaimramlan zaimramlan commented Oct 14, 2019

This worked for me using rbenv, thanks for sharing!

@gamesover

This comment has been minimized.

Copy link

@gamesover gamesover commented Dec 17, 2020

I am using ubuntu and rbenv. I have to reinstall ruby by rbenv to resolve the issue

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