Skip to content

Instantly share code, notes, and snippets.

@soultech67
Last active June 6, 2022 21:18
Show Gist options
  • Save soultech67/33ba09706e091c06ce66684cd28015ac to your computer and use it in GitHub Desktop.
Save soultech67/33ba09706e091c06ce66684cd28015ac to your computer and use it in GitHub Desktop.
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:

@grillermo
Copy link

Thank you, you da mvp

@fdominguezclaro
Copy link

Thanks! Works great with rbenv.

@ritec
Copy link

ritec commented Mar 21, 2019

Thanks for this writeup good sir.

@sharkeyryan
Copy link

This worked for me under rbenv installing 2.6.1.

Thanks!

@DanteCavero
Copy link

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

@Willdta
Copy link

Willdta commented Jun 4, 2019

Thank you!

@chrisZingel
Copy link

Thank you. Works great with rbenv

@bricemaurin
Copy link

This worked for me using rbenv, thanks !

@yuto2121
Copy link

yuto2121 commented Jul 1, 2019

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

@Yorkshireman
Copy link

👍

@MatthewTFarley
Copy link

rbenv solution just works. Thank you! 👍

@LilyMarcela
Copy link

rbenv solution works perfectly, thank you 👍

@zaimramlan
Copy link

This worked for me using rbenv, thanks for sharing!

@gamesover
Copy link

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