Library not loaded: libreadline

Published on Christian Mayer's Weblog

After upgrading Homebrew to version 1.1.0 a few programs were broken.

Like pry:

$ bundler exec ./bin/dev
Sorry, you can't use Pry without Readline or a compatible library.
Possible solutions:
 * Rebuild Ruby with Readline support using `--with-readline`
 * Use the rb-readline gem, which is a pure-Ruby port of Readline
 * Use the pry-coolline gem, a pure-ruby alternative to Readline
bundler: failed to load command: ./bin/dev (./bin/dev)
LoadError: dlopen(/Users/thefox/.rbenv/versions/2.3.1/lib/ruby/2.3.0/x86_64-darwin14/readline.bundle, 9): Library not loaded: /usr/local/opt/readline/lib/libreadline.6.dylib

Even rbenv is not working anymore:

$ rbenv install 2.3.1
rbenv: /Users/thefox/.rbenv/versions/2.3.1 already exists
continue with installation? (y/N) y
Downloading ruby-2.3.1.tar.bz2...
-> https://cache.ruby-lang.org/pub/ruby/2.3/ruby-2.3.1.tar.bz2
Installing ruby-2.3.1...

BUILD FAILED (OS X 10.10.5 using ruby-build 20160602)

Inspect or clean up the working tree at /var/folders/fb/46
Results logged to /var/folders/fb/46.log

Last 10 log lines:
configure: ruby library version = 2.3.0
configure: creating ./config.status
config.status: creating GNUmakefile
dyld: Library not loaded: /usr/local/opt/readline/lib/libreadline.6.dylib
  Referenced from: /usr/local/bin/awk
  Reason: image not found

So you cannot reinstall Ruby.

You need to uninstall all versions of readline first.

$ brew uninstall --force readline
$ brew install readline

In my case awk was affected too.

$ awk
dyld: Library not loaded: /usr/local/opt/readline/lib/libreadline.6.dylib
  Referenced from: /usr/local/bin/awk
  Reason: image not found
Trace/BPT trap: 5

So I needed to reinstall awk (gawk) as well.

$ brew uninstall --force gawk
$ brew install gawk

After that I was able to reinstall Ruby version 2.3.1 using rbenv.

Conclusion: You need to reinstall readline and all programs that uses readline.

More Resources

Recent Posts

About the Author

Christian is a professional software developer living in Vienna, Austria. He loves coffee and is strongly addicted to music. In his spare time he writes open source software. He is known for developing automatic data processing systems on Debian Linux server.

Categories: Productivity
Tags: Homebrew, macOS, OSX, readline, Ruby, rbenv, pry, install, uninstall, reinstall

Archive | Categories | RSS Feed | Usage | Imprint
Copyright © 2006 by