使用Homebrew安装icu4c 63版本

34

我正在尝试启动 psql, 但是出现了错误

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"?

当我使用postgres -D /usr/local/var/postgres时,遇到了以下错误:

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

通过快速搜索 libicui18n.63.dylib,我发现我需要安装版本为 63 的 icu4c 库。但是,brew list icu4c 显示我已经安装了版本为 64.2 的库。

我尝试使用 brew install icu4c 63brew install icu4c@63 命令,但都没有成功。

请问有人能提供帮助吗?非常感谢!

4个回答

127
解决方案:
  1. 进入Homebrew的formula目录
  • Intel
cd $(brew --prefix)/Homebrew/Library/Taps/homebrew/homebrew-core/Formula
  • M1
    cd $(brew --prefix)/Library/Taps/homebrew/homebrew-core/Formula
    
    1. 查找所需的提交记录(icu4c版本63)以进行检出。
    git log --follow icu4c.rb
    
    1. 切换到新分支
    git checkout -b icu4c-63 e7f0f10dc63b1dc1061d475f1a61d01b70ef2cb7
    
    1. 使用新版本重新安装该库
    brew reinstall ./icu4c.rb
    
    1. 切换到重新安装的版本
    brew switch icu4c 63.1
    
    1. 切换回主分支
    git checkout master
    

    来源:

    如果您使用这个命令超过一次,这里还有一个小贴士:

    # 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
    5
    安装较旧版本的 Homebrew 的方法绝对很棒,比我看到的其他方法要容易得多,非常感谢! - leo
    非常感谢! - Marcello Infoweb
    3
    如果您在Git日志中无法找到所需的版本,可以尝试先下载完整历史记录,命令为 git -C "$(brew --repo homebrew/core)" fetch --unshallow。这将帮助您获取更多的版本历史记录信息。 - Lipdk
    1
    这帮助我在我的MacOS上将Postgres从13.4升级到14.6,谢谢! - Sergey Shcherbakov
    显示剩余4条评论

    15

    就像@dingusjh所说,但如果brew抱怨已经安装了icu4c并且建议你尝试extract的话,请使用reinstall命令而不是install命令。完整命令如下:

    brew reinstall https://raw.githubusercontent.com/Homebrew/homebrew-core/e7f0f10dc63b1dc1061d475f1a61d01b70ef2cb7/Formula/icu4c.rb
    

    2
    最初的回答
    这应该更容易了。
    brew install https://raw.githubusercontent.com/Homebrew/homebrew-core/e7f0f10dc63b1dc1061d475f1a61d01b70ef2cb7/Formula/icu4c.rb
    

    我以前用过这种方法处理其他公式,但在这种情况下它不起作用。给了我一个建议,使用brew extract代替,并警告说“icu4c 63.1已经安装并更新\n要重新安装63.1,请运行brew reinstall icu4c”...运行重新安装命令重新安装了最新版本(截至本文写作时为64.2)。不知道这是新的brew行为还是错误或其他原因。回到像ogirginc答案中所述的从本地brew tap获取它的方式。 - henry

    1

    对我来说,重新安装icu4c解决了问题 brew reinstall icu4c


    老实说,这是人们应该首先尝试的!很好的答案。 - just.jules

    网页内容由stack overflow 提供, 点击上面的
    可以查看英文原文,
    原文链接