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.
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.
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 runbundle 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 thencd project-folder
back into my project so that rvm would reactivate my gemset. - I ran
gem install bundler
and thenbundle install
to re-hydrate the gems for my project. - and then I was off to the races again.
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
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
- rvm:
- rbenv:
- xcode:
- some other work-arounds: