28

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.

ogirginc
  • 4,326
  • 3
  • 26
  • 41

4 Answers4

116

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:

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
}
ogirginc
  • 4,326
  • 3
  • 26
  • 41
  • By the way, if anyone know a better/easier way to do this & share, I would really appreciate it :) – ogirginc Apr 24 '19 at 10:58
  • 4
    Abslutely fantastic way to install an older version in brew, much easier than other methods I've seen, thanks a lot! – leo Jun 23 '19 at 09:05
  • this worked! but it sounded like it had the potential to brick my machine! My case was: installed phpbrew php7.3, then npm and node didn't work – santiago arizti Aug 02 '19 at 22:09
  • It's quite safe. In worst case senario, you would have to reinstall php/node. :) – ogirginc Aug 05 '19 at 12:47
  • Muito Obrigado! – Marcello Infoweb Apr 24 '20 at 13:43
  • Looks like version 63 and before have been removed from the log. – lacy Jul 20 '20 at 21:41
  • @lacy I don't think anyone would force push in homebrew-core but checked just to be sure and can confirm it is still there. – ogirginc Jul 22 '20 at 12:58
  • 2
    If by any reason you can't see the version that you need in the git log, you can try to download the full-history before, `git -C "$(brew --repo homebrew/core)" fetch --unshallow` – Lipdk Sep 11 '20 at 14:01
15

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
wloske
  • 189
  • 1
  • 6
2

This should be easier.

brew install https://raw.githubusercontent.com/Homebrew/homebrew-core/e7f0f10dc63b1dc1061d475f1a61d01b70ef2cb7/Formula/icu4c.rb
dingusjh
  • 21
  • 1
  • I've used this method with other formulae in the past, but it didn't work in this case. Gave me a recommendation to use `brew extract` instead, and the warning "icu4c 63.1 is already installed and up-to-date \n To reinstall 63.1, run `brew reinstall icu4c`"… running the reinstall command reinstalled the latest (64.2 as of this writing). Don't know if that's a new brew behavior or bug or what. Went back to getting it from the local brew tap as in ogirginc's answer – henry Jul 25 '19 at 22:35
0

For me reinstalling icu4c worked brew reinstall icu4c

A. KUMAR
  • 128
  • 7