Library not loaded: /usr/local/opt/readline/lib/libreadline.6.2.dylib

PostgresqlPsqlLibreadline

Postgresql Problem Overview


I just installed posgresql with homebrew and when I go on to type the command

psql

I get the following error:

dyld: Library not loaded: /usr/local/opt/readline/lib/libreadline.6.2.dylib
Referenced from: /usr/local/bin/psql
Reason: image not found
[1]    69711 trace trap  psql

Does anyone have any idea about what's wrong?

Postgresql Solutions


Solution 1 - Postgresql

I was getting the exact same error, but the above answers didn't work for me. I had to reinstall postgresql.

brew reinstall postgresql

Solution 2 - Postgresql

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:

  1. Go to homebrew-core directory:
    $ cd $(brew --repository)/Library/Taps/homebrew/homebrew-core
  1. Check the hash for old Formula:
    $ git log master -- Formula/readline.rb
  1. Find the corresponding version of the hash value
    commit 1dd4221c35716d6bec363ad3425ef93ffe7d9b9f
    Author: BrewTestBot <brew-test-bot@googlegroups.com>
    Date:   Wed Aug 15 21:51:16 2018 +0000
    
        readline: update 7.0.5 bottle.
  1. Checkout to old formula:
    $ git checkout 1dd4221c35716d6bec363ad3425ef93ffe7d9b9f Formula/readline.rb
  1. Reinstall the formula:
    $ brew reinstall readline
  1. Reset the repo

Following those steps, you can reinstall the old version of formula.

Solution 3 - Postgresql

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

Solution 4 - Postgresql

If you don't have readline installed, first install it:

brew install readline

For me, I was getting this error, even though I had readline installed. Reinstalling readline did the trick:

brew reinstall readline

Solution 5 - Postgresql

This worked for me

brew switch readline

This would display the versions you have installed. Pick one out of them. I picked 7.0.5

I then ran

brew switch readline 7.0.5

The readline version got updated, and psql ran smoothly.

Solution 6 - Postgresql

this worked for me

ln -s /usr/local/opt/readline/lib/libreadline.7.0.dylib /usr/local/opt/readline/lib/libreadline.6.dylib

Solution 7 - Postgresql

The solution is to force the linking of readline again.

brew remove readline
brew install readline
brew link readline --force

Solution 8 - Postgresql

It seems to me the problem is about update readline package. postgres tryied to use /usr/local/opt/readline/lib/libreadline.7.dylib in my case. So i just created a symlink to existing version of library /usr/local/opt/readline/lib/libreadline.8.dylib.

worked for me:

ln -s /usr/local/opt/readline/lib/libreadline.8.dylib /usr/local/opt/readline/lib/libreadline.7.dylib

Solution 9 - Postgresql

None of those solutions worked for me; I had to run :

brew upgrade bash

from : https://github.com/Homebrew/homebrew-core/issues/5799

Solution 10 - Postgresql

The answer above didn't work for me so I wanted to post what did eventually work. Based on a thread I found here, I had to uninstall readline and the install it again but from source.

brew uninstall readline
brew install --build-from-source readline

After that the psql error went away.

Solution 11 - Postgresql

I had this issue, and the key for me was to reinstall both readline and postgres. Once postgres was reinstalled, the issue was resolved.

Solution 12 - Postgresql

Another way to fix psql is update postgresql just running brew upgrade postgresql since the newest version will use readline 7 version.

Solution 13 - Postgresql

I had this problem when I updated readline to version 7 by accident. I uninstalled readline and brew remind me 6.3.8 is still installed. It seems that version 7 is not working with PSQL at the moment.

Solution 14 - Postgresql

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


Solution 15 - Postgresql

I tried all the previews answers, and nothing worked. The only thing that really worked for me was:

brew link postgresql

Solution 16 - Postgresql

The following commands worked for me:

brew reinstall postgresql
brew postgresql-upgrade-database

Solution 17 - Postgresql

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

Solution 18 - Postgresql

I found this solution helpful

brew upgrade bash

https://github.com/Homebrew/homebrew-core/issues/5799

Solution 19 - Postgresql

You could try brew doctor and see what it says.

Possibly all you need is brew link --overwrite bash.

For me, I just upgraded brew since OS X EL Capitan had some security upgrade that affetcs my /usr folder. During the brew upgrade, the bash link is broken, and this is what brew doctor tells me.

So I just run brew link --overwrite bash and everything's fine.

Solution 20 - Postgresql

You might want to check if you have anything else symlinked to postgresql. I had previously linked to the postgres93 package, which, as of May '17, is unsupported and has been removed. Removing that link and then relinking worked for me:

brew unlink postgresql93
brew link postgresql

Solution 21 - Postgresql

In my case the correct answer did not fix the problem.

The problem started after running brew doctor and adding export PATH="/usr/local/bin:$PATH" to my ~/.zshrc file.

Removing

export PATH="/usr/local/bin:$PATH" 

from ~/.zshrc got it solved.

Solution 22 - Postgresql

For some unknown reason, when this error popped up for the next version of Readline, my RVM seemed unable to locate the right one no matter how I symlinked it, throwing:

Library not loaded: /usr/local/opt/readline/lib/libreadline.7.dylib (LoadError)

I ended up adding the gem rb-readline to my Gemfile and doing another bundle install and it started working.

I... just don't know.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionhbejgelView Question on Stackoverflow
Solution 1 - PostgresqldafunkeemonkeeView Answer on Stackoverflow
Solution 2 - PostgresqlStephenView Answer on Stackoverflow
Solution 3 - Postgresqlanvy zhangView Answer on Stackoverflow
Solution 4 - PostgresqlTroyView Answer on Stackoverflow
Solution 5 - Postgresqlsindhu_spView Answer on Stackoverflow
Solution 6 - PostgresqlJonView Answer on Stackoverflow
Solution 7 - PostgresqlAlex PalcuieView Answer on Stackoverflow
Solution 8 - PostgresqlEugeny MaksimovView Answer on Stackoverflow
Solution 9 - PostgresqlAnthony DahanneView Answer on Stackoverflow
Solution 10 - PostgresqlMark PruceView Answer on Stackoverflow
Solution 11 - PostgresqlMicah BalesView Answer on Stackoverflow
Solution 12 - PostgresqlzegomesjfView Answer on Stackoverflow
Solution 13 - PostgresqlYuanqi CaoView Answer on Stackoverflow
Solution 14 - PostgresqlPrince AbaloguView Answer on Stackoverflow
Solution 15 - PostgresqlfinxView Answer on Stackoverflow
Solution 16 - Postgresqlnilansh bansalView Answer on Stackoverflow
Solution 17 - Postgresqlph4n70mView Answer on Stackoverflow
Solution 18 - PostgresqlTornikeView Answer on Stackoverflow
Solution 19 - PostgresqlHustlionView Answer on Stackoverflow
Solution 20 - Postgresqlsp89View Answer on Stackoverflow
Solution 21 - Postgresqluser9869932View Answer on Stackoverflow
Solution 22 - PostgresqlErik TrautmanView Answer on Stackoverflow