Can't run psql command, keep getting the same

2019-01-30 09:22发布

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?

20条回答
Deceive 欺骗
2楼-- · 2019-01-30 09:59

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.

查看更多
混吃等死
3楼-- · 2019-01-30 10:01

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.

查看更多
放我归山
4楼-- · 2019-01-30 10:03

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.

查看更多
爱情/是我丢掉的垃圾
5楼-- · 2019-01-30 10:05

The solution is to force the linking of readline again.

brew remove readline
brew install readline
brew link readline --force
查看更多
仙女界的扛把子
6楼-- · 2019-01-30 10:06

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

brew reinstall postgresql

查看更多
Explosion°爆炸
7楼-- · 2019-01-30 10:07

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 different version of readline, I think you should consider upgrading.

查看更多
登录 后发表回答