Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error in installing PostgreSQL in macOS using HomeBrew

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.

like image 647
Dustine Rene Bernasor Avatar asked May 23 '26 13:05

Dustine Rene Bernasor


2 Answers

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
like image 50
bleubird Avatar answered May 26 '26 06:05

bleubird


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.

like image 26
forforf Avatar answered May 26 '26 05:05

forforf



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!