Error in installing PostgreSQL in macOS using HomeBrew
Asked Answered
M

2

6

I was experimenting on macOS and tried

  1. installing postgresql@11 using HomeBrew. Everything went well at first.
  2. After that, I uninstalled it
  3. this time installed postgresql@14 which went fine too.
  4. I uninstalled postgresql@14
  5. I wanted to install postgresql@11 again

but this time I am having problems.

*dyld[78742]: Library not loaded: /opt/homebrew/opt/icu4c/lib/libicui18n.73.dylib
  Referenced from: <0F8BEC0C-41F5-3781-B77A-20C013908EA6> /opt/homebrew/Cellar/postgresql@11/11.22_1/bin/postgres
  Reason: tried: '/opt/homebrew/opt/icu4c/lib/libicui18n.73.dylib' (no such file),
'/System/Volumes/Preboot/Cryptexes/OS/opt/homebrew/opt/icu4c/lib/libicui18n.73.dylib' (no such file),
'/opt/homebrew/opt/icu4c/lib/libicui18n.73.dylib' (no such file), 
'/usr/local/lib/libicui18n.73.dylib' (no such file), 
'/usr/lib/libicui18n.73.dylib' (no such file, not in dyld cache), 
'/opt/homebrew/Cellar/icu4c/74.2/lib/libicui18n.73.dylib' (no such file), 
'/System/Volumes/Preboot/Cryptexes/OS/opt/homebrew/Cellar/icu4c/74.2/lib/libicui18n.73.dylib' (no such file), 
'/opt/homebrew/Cellar/icu4c/74.2/lib/libicui18n.73.dylib' (no such file),
'/usr/local/lib/libicui18n.73.dylib' (no such file), 
'/usr/lib/libicui18n.73.dylib' (no such file, not in dyld cache)
no data was returned by command ""/opt/homebrew/Cellar/postgresql@11/11.22_1/bin/postgres" -V"
The program "postgres" is needed by initdb but was not found in the same directory as "/opt/homebrew/Cellar/postgresql@11/11.22_1/bin/initdb".
Check your installation.

I can start postgresql@11 as a service but when I run psql, I get this:

psql: could not connect to server: Connection refused
Is the server running locally and accepting connections on Unix domain socket "/tmp/.s.PGSQL.5432"?

I tried brew link --overwrite postgresql@11 but I still get the same problems.

Mouthwash answered 13/3, 2024 at 11:19 Comment(2)
Probably that is becasue default port 5432 is in use by version 14? Maybe this helps. On Mac, my preference is to use Postgres.app from postgresapp.com/downloads.html. Although current versions do not have 11, I believe you can find it too in older downloads. Or another option I often use is Docker containers for postgress, in fact I have multiple versions of postgreSQL running in Docker containers both in Mac and Windows.Deepseated
Thank you for this. I found PostgreSQL 11 under legacy downloads in the link you provided. This is another option.Mouthwash
S
5

I ran into this issue as well after I restarted my computer after updating a bunch of applications. By checking the /usr/local/var/log/[email protected], I could see that postgresql@11 was looking for version 73 of icu4c. In your error message, you can see lines like /opt/homebrew/Cellar/icu4c/74.2/lib/libicui18n.73.dylib which is looking for a version 73 file under the 74.2 folder. To see which version of icu4c you currently have, run:

brew info icu4c

Upgrading to postgresql@14 may have updated your version to 74. The solution presented in this in this post was able to resolve my issue. Specifically for the latest 73:

wget https://raw.githubusercontent.com/Homebrew/homebrew-core/9ca237a7bc85e854c8465c9ad08f8a333ba27a44/Formula/i/icu4c.rb
brew install icu4c

followed by restarting postgresql@11

brew services restart postgresql@11

To get a different version of icu4c, search through the history homebrew-core repo for the version you need and then select the Raw button to grab the URL.

Additionally, if you get Library not loaded errors when running wget for the first time, try reinstalling it:

brew reinstall wget
Spile answered 27/3, 2024 at 19:12 Comment(2)
This doesn't work for me. When I run brew install after downloading the formula for the older version of icu4c, brew tries to install the latest version of icu4c again.Roubaix
Managed to get this working after doing brew install --formula ./icu4c.rb && brew reinstall --formula ./icu4c.rbRoubaix
O
0

I was trying to upgrade from postgresql@14/14.10_1 to postgresql@16/16.4 and received a similar error:

 Library not loaded: '/opt/homebrew/opt/icu4c/lib/libicui18n.73.dylib

In my case I had brew update && brew install postgresql@16, which put the icu4c library at v74, not v73, causing the failure.

I did the following steps:

brew reinstall postgres@14 # this bumped the version to 14.13
brew cleanup # not sure if this did anything
# Upgrade using the new v14 to v16
/opt/homebrew/Cellar/postgresql@16/16.4/bin/pg_upgrade -b /opt/homebrew/Cellar/postgresql@14/14.13/bin -B /opt/homebrew/Cellar/postgresql@16/16.4/bin -d /opt/homebrew/var/postgresql@14 -D /opt/homebrew/var/postgresql@16
brew uninstall postgresql@14
brew services start postgresql@16

and it worked.

Ogg answered 5/10, 2024 at 17:1 Comment(0)

© 2022 - 2025 — McMap. All rights reserved.