50

I'm no Homebrew expert but I think it has "upgraded" me from readline version 6.x to 7.0 sometime after 9/15/16:

eat@eric-macbook:Homebrew$ 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)

This has caused headaches for my 9.4.5 Homebrew version of Postgresql (I need the older 9.4 for comparability reasons):

eat@eric-macbook:~$ psql --version
dyld: Library not loaded: /usr/local/opt/readline/lib/libreadline.6.dylib
  Referenced from: /usr/local/Cellar/postgresql/9.4.5/bin/psql
  Reason: image not found
Trace/BPT trap: 5

Unfortunately I can't find a 6.x version of readline on Homebrew to revert to - only 7.0 seems to be available(?).

My question is twofold:

  • Is the the readline version mismatch the cause of my postgres/psql problem?
  • If so, how do I return to 6.x with Homebrew to correct the problem?

Thank you in advance!

ericky
  • 1,641
  • 2
  • 14
  • 16

6 Answers6

61

To answer the specific question.

You can switch between version of installed brew packages which are still around locally as explained in this question: Homebrew install specific version of formula?

To downgrade to readline 6.x the following command worked for me:

brew switch readline 6.3.8
Community
  • 1
  • 1
DanEEStar
  • 6,140
  • 6
  • 37
  • 52
  • 10
    Thx, but I am familiar with `brew switch`. As shown by the `brew info readline` output above, I don't have v 6.x locally. I can't find that version available for download on Homebrew (`brew search readline`). The specific question is: how to obtain it if no longer present on your machine? – ericky Oct 26 '16 at 18:44
27

Just reinstall postgresql94 package, the PostgreSQL 9.4 will use the new readline package:

brew reinstall postgresql94
vitalie
  • 445
  • 4
  • 4
25

NOTE: This answer might be outdated due to the changes in the branch (as reported by Andrew, the commit disappear)

To those who still facing this issue but cannot download the readline 6.3.8 from the homebrew package. You can try this solution. (Refer from here)

# Uninstall this incompatible version
brew uninstall readline

# Go to the local clone of homebrew-core
cd $(brew --prefix)/Homebrew/Library/Taps/homebrew/homebrew-core

# Move to the homebrew-core revision that had 6.3.8
git checkout 35fed817726f61a9d40c8420582f6fde59eb5f14

# Re-install readline
brew reinstall readline

# Switch back to HEAD
git checkout master

# Pin readline so this can't happen again
brew pin readline
Sam Kah Chiin
  • 4,375
  • 5
  • 25
  • 30
  • This seems to no longer work because that commit ref. is no longer valid. Not sure why, but it's not in the history either. – Andrew Dec 15 '16 at 21:48
  • Thanks so much!! This worked for me on MacOS Sierra (and I didn't have 6.3.8 anymore). I'm running postgres 9.4.9. I copied the commands from the link. Worked without a hitch. – risa_risa Jan 05 '17 at 22:34
4

For people coming from Rails with this issue you can just add the readline gem and run bundle install.

gem 'rb-readline' #Fixed readline error
bkunzi01
  • 4,504
  • 1
  • 18
  • 25
  • For better search indexing if anyone else has the same issue: Upgrading `readline` from 7.0.0 to 8.0.0 triggered this for me and I got the error `Bundler::GemRequireError: There was an error while trying to load the gem 'pry-byebug'. Gem Load Error is: uninitialized constant Byebug::LocalInterface::Readline`. Make sure to also add `gem rb-readline` globally if you use `pry` over `irb` with this issue. – David Bodow Feb 14 '19 at 04:34
1

I was able to overcome this with a blanket brew upgrade (upgrade all brew-managed packages).

Seth Bro
  • 2,537
  • 3
  • 19
  • 15
0

If you would use Sam Kah Chiin's solution, you can ignore the 404.

Apply the extra change so it would work on new macOS:

diff --git a/Formula/readline.rb b/Formula/readline.rb
index 08d3728..d67e5e4 100644
--- a/Formula/readline.rb
+++ b/Formula/readline.rb
@@ -16,7 +16,7 @@ class Readline < Formula
     sha256 "c129333634dd00ab2267ae9c531fca1f5cc50dd519ed3399918289fdfdf2663b" => :lion
   end

-  keg_only :shadowed_by_osx, <<-EOS.undent
+  keg_only :shadowed_by_macos, <<~EOS
     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.

Do sudo update_dyld_shared_cache at the end

user2679290
  • 144
  • 9