I just installed posgresql with homebrew and when I go on to type the command
psql
I get the following error:
dyld: Library
None of those solutions worked for me; I had to run :
brew upgrade bash
from : https://github.com/Homebrew/homebrew-core/issues/5799
I tried all these terminal commands and nothing worked so decided to fix it manually..
Open finder and hit command+shift+g
Go to this folder /usr/local/opt/readline/lib/
you should see multiple versions of these files
libreadline.6.dylib
libreadline.7.0.dylib
rename any of them to whichever library is not loaded
this is: /usr/local/opt/readline/lib/libreadline.6.2.dylib
mine was: /usr/local/opt/readline/lib/libreadline.6.dylib
I found this solution helpful
brew upgrade bash
https://github.com/Homebrew/homebrew-core/issues/5799
If the situation is you have a higher version readline say 7.0. You can do this
cd /usr/local/opt/readline/lib
ln libreadline.7.0.dylib libreadline.6.2.dylib
The key problem is that your postgresql was trying to find the libreadline.6.2.dylib
but your readline
is version 7.0
, so only 7's lib is linked.
I don't think upgrading postgresql is a good idea, it's not easy and may cause a lot of problem, especially when you already have database data.
What I do, is to switch the version of readline
. When you check brew info readline
, you will find different versions, mine is 6.3.8
, so I switch to that version by executing:
$ brew switch readline 6.3.8
It will change to 6.3.8 and create the link:
Cleaning /usr/local/Cellar/readline/6.3.8
Cleaning /usr/local/Cellar/readline/7.0.1
Opt link created for /usr/local/Cellar/readline/6.3.8
In this case, all the linked lib becomes to 6 version, and command line works:
$ ls /usr/local/opt/readline/lib/
libhistory.6.2.dylib libhistory.dylib libreadline.a
libhistory.6.3.dylib libreadline.6.2.dylib libreadline.dylib
libhistory.6.dylib libreadline.6.3.dylib
libhistory.a libreadline.6.dylib
However, if you have different apps using the different version of readline, I think you should consider upgrading.
Update: 06/02/2019
What if the old version is not installed?
Homebrew
doesn't provide a way to install old version formula. And since v2.0.0, it will run brew cleanup
as default behaviours every 30 days. Therefore, you may accidentally update brew
and delete the old version.
Here are the steps to install old version:
homebrew-core
directory: $ cd $(brew --repository)/Library/Taps/homebrew/homebrew-core
$ git log master -- Formula/readline.rb
commit 1dd4221c35716d6bec363ad3425ef93ffe7d9b9f
Author: BrewTestBot <brew-test-bot@googlegroups.com>
Date: Wed Aug 15 21:51:16 2018 +0000
readline: update 7.0.5 bottle.
$ git checkout 1dd4221c35716d6bec363ad3425ef93ffe7d9b9f Formula/readline.rb
$ brew reinstall readline
Following those steps, you can reinstall the old version of formula.
This had helped me: uninstall all readline and postgresql
export CPPFLAGS=-I/usr/local/opt/readline/include export LDFLAGS=-L/usr/local/opt/readline/lib
and install posqtgresql