Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Install icu4c version 63 with Homebrew

I was trying to start psql but got

psql: could not connect to server: No such file or directory
    Is the server running locally and accepting
    connections on Unix domain socket "/tmp/.s.PGSQL.5432"?

When I used postgres -D /usr/local/var/postgres, got the following error:

dyld: Library not loaded: /usr/local/opt/icu4c/lib/libicui18n.63.dylib
  Referenced from: /usr/local/bin/postgres
  Reason: image not found
[1]    2559 abort      postgres -D /usr/local/var/postgres

A quick search on libicui18n.63.dylib showed me I need icu4c lib with version 63. However brew list icu4c says I have the version 64.2.

I tried both brew install icu4c 63 & brew install icu4c@63 but no luck.

Can anyone help, please? Thanks in advance.

like image 988
ogirginc Avatar asked Apr 24 '19 09:04

ogirginc


3 Answers

Solution:

  1. cd to Homebrew's formula directory
  • Intel
    cd $(brew --prefix)/Homebrew/Library/Taps/homebrew/homebrew-core/Formula 
  • M1
    cd $(brew --prefix)/Library/Taps/homebrew/homebrew-core/Formula 
  1. Find desired commit (version 63 for icu4c) to checkout
git log --follow icu4c.rb 
  1. Checkout to a new branch
git checkout -b icu4c-63 e7f0f10dc63b1dc1061d475f1a61d01b70ef2cb7 
  1. Reinstall the library with the new version
brew reinstall ./icu4c.rb 
  1. Switch to the reinstalled version
brew switch icu4c 63.1 
  1. Checkout back to master
git checkout master 

Sources:

  • Homebrew install specific version of formula?
  • http://hanxue-it.blogspot.com/2018/08/macos-homebrew-installing-older-version-of-software.html

Bonus for those who ended up using this more than once:

# zsh function hiicu63() {   local last_dir=$(pwd)    cd $(brew --prefix)/Homebrew/Library/Taps/homebrew/homebrew-core/Formula   git checkout icu4c-63   brew reinstall ./icu4c.rb   brew switch icu4c 63.1   git checkout master    cd $last_dir } 
like image 177
ogirginc Avatar answered Oct 16 '22 22:10

ogirginc


Like @dingusjh says, but use reinstall command instead of install in case brew complains about having icu4c installed already and you should try to extract. The complete command would then be:

brew reinstall https://raw.githubusercontent.com/Homebrew/homebrew-core/e7f0f10dc63b1dc1061d475f1a61d01b70ef2cb7/Formula/icu4c.rb
like image 45
wloske Avatar answered Oct 16 '22 22:10

wloske


This should be easier.

brew install https://raw.githubusercontent.com/Homebrew/homebrew-core/e7f0f10dc63b1dc1061d475f1a61d01b70ef2cb7/Formula/icu4c.rb
like image 29
dingusjh Avatar answered Oct 16 '22 21:10

dingusjh