brew icon indicating copy to clipboard operation
brew copied to clipboard

psql Library not loaded: /usr/local/lib/libpq.5.dylib

Open applemate opened this issue 1 year ago • 7 comments

brew doctor output

Please note that these warnings are just used to help the Homebrew maintainers
with debugging if you file an issue. If everything you use Homebrew for is
working fine: please don't worry or file an issue; just ignore this. Thanks!

Warning: Some installed casks are deprecated or disabled.
You should find replacements for the following casks:
  ksdiff

Warning: A newer Command Line Tools release is available.
Update them from Software Update in System Settings.

If that doesn't show you any updates, run:
  sudo rm -rf /Library/Developer/CommandLineTools
  sudo xcode-select --install

Alternatively, manually download them from:
  https://developer.apple.com/download/all/.
You should download the Command Line Tools for Xcode 15.1.


Warning: Some installed formulae are deprecated or disabled.
You should find replacements for the following formulae:
  [email protected]

Warning: Unbrewed header files were found in /usr/local/include.
If you didn't put them there on purpose they could cause problems when
building Homebrew formulae, and may need to be deleted.


➜  ~

Verification

  • [X] My "brew doctor output" above says Your system is ready to brew. and am still able to reproduce my issue.
  • [X] I ran brew update twice and am still able to reproduce my issue.
  • [X] This issue's title and/or description do not reference a single formula e.g. brew install wget. If they do, open an issue at https://github.com/Homebrew/homebrew-core/issues/new/choose instead.

brew config output

HOMEBREW_VERSION: 4.2.20
ORIGIN: https://github.com/Homebrew/brew
HEAD: c2ed3327c605c3e738359c9807b8f4cd6fec09eb
Last commit: 2 days ago
Core tap JSON: 30 Apr 17:13 UTC
Core cask tap JSON: 30 Apr 17:13 UTC
HOMEBREW_PREFIX: /opt/homebrew
HOMEBREW_CASK_OPTS: []
HOMEBREW_MAKE_JOBS: 10
Homebrew Ruby: 3.1.4 => /opt/homebrew/Library/Homebrew/vendor/portable-ruby/3.1.4/bin/ruby
CPU: 10-core 64-bit arm_firestorm_icestorm
Clang: 14.0.3 build 1403
Git: 2.44.0 => /opt/homebrew/bin/git
Curl: 8.1.2 => /usr/bin/curl
macOS: 13.5.1-arm64
CLT: 14.3.1.0.1.1683849156
Xcode: N/A
Rosetta 2: false

What were you trying to do (and why)?

I install postgres 16 and run it. When I try the command psql, I got this error

CleanShot 2024-05-01 at 00 16 32

What happened (include all command output)?

dyld[28821]: Library not loaded: /usr/local/lib/libpq.5.dylib Referenced from: <4A4C9EBE-1868-317F-A86C-2DAE62CA9064> /usr/local/bin/psql Reason: tried: '/usr/local/lib/libpq.5.dylib' (no such file), '/System/Volumes/Preboot/Cryptexes/OS/usr/local/lib/libpq.5.dylib' (no such file), '/usr/local/lib/libpq.5.dylib' (no such file), '/usr/lib/libpq.5.dylib' (no such file, not in dyld cache) [1] 28821 abort psql

What did you expect to happen?

postgres database should run

Step-by-step reproduction instructions (by running brew commands)

brew install postgresql@16
brew services start postgresql@16
brew services list
psql

applemate avatar Apr 30 '24 17:04 applemate

What's the output of psql --version? I'm guessing it's not 16.x, since postgresql@16 is keg-only.

Also check the output of ls -l /usr/local/bin/psql.

gromgit avatar Apr 30 '24 17:04 gromgit

CleanShot 2024-05-01 at 00 46 36

applemate avatar Apr 30 '24 17:04 applemate

CleanShot 2024-05-01 at 00 47 25

applemate avatar Apr 30 '24 17:04 applemate

CleanShot 2024-05-01 at 00 47 25

That's not Homebrew's psql, and I should've noticed earlier that you're running on an ARM64 Mac, for which Homebrew installs exclusively under /opt/homebrew.

You're looking for /opt/homebrew/opt/postgresql@16/bin/psql instead.

gromgit avatar Apr 30 '24 18:04 gromgit

CleanShot 2024-05-01 at 01 03 26

applemate avatar Apr 30 '24 18:04 applemate

Yeah, that's the psql you want to run.

gromgit avatar Apr 30 '24 18:04 gromgit

How can I run that one ?

applemate avatar Apr 30 '24 18:04 applemate

Just like that: /opt/homebrew/opt/postgresql@16/bin/psql.

gromgit avatar May 01 '24 01:05 gromgit

CleanShot 2024-05-01 at 12 29 09

Now I got database not found, how can I create/edit database if I can't run postgres ?

applemate avatar May 01 '24 05:05 applemate

You're asking us how to use PostgreSQL at this point which is not an issue with Homebrew.

MikeMcQuaid avatar May 01 '24 07:05 MikeMcQuaid

I solved this I just do this rm -rf /usr/local/bin/psql And remove all postgres that were installed by homebrew Then install postgres app from https://postgresapp.com/downloads.html Now my psql commpand works

CleanShot 2024-05-01 at 15 04 20

applemate avatar May 01 '24 08:05 applemate