brew升级后php不可用报Library not loaded

早上用brew装了下tmux,中间过程中可能把某些软件包给升级了,当执行php的就报错:

dyld[90074]: Library not loaded: /usr/local/opt/icu4c/lib/libicuio.70.dylib
  Referenced from: <97A6C2AA-7161-357C-A081-F439B35C0C10> /usr/local/Cellar/php@7.4/7.4.30/bin/php
  Reason: tried: '/usr/local/opt/icu4c/lib/libicuio.70.dylib' (no such file), '/System/Volumes/Preboot/Cryptexes/OS/usr/local/opt/icu4c/lib/libicuio.70.dylib' (no such file), '/usr/local/opt/icu4c/lib/libicuio.70.dylib' (no such file), '/usr/local/lib/libicuio.70.dylib' (no such file), '/usr/lib/libicuio.70.dylib' (no such file, not in dyld cache)

这下本地开发环境直接崩了,手头还有东西要改要测试,有点慌。

查了下是icu4c版本的问题,当前是72.1,而php@7.4需要的是70。

首先想到的直接brew install icu4c@70,不管用。

找了一圈,有个答案看起来要还靠谱些,原理是把brew的Formula先切到icu4c 70版本,安装完成后再切回来。一步步做下去,结果到最后一步brew switch icu4c 70.1时报错了,说swtich命令不存在,用link命令也不行。最后没办法,直接把安装后的70.1的文件拷到/usr/local/opt/icu4c完事。

完整命令:

cd $(brew --prefix)/Homebrew/Library/Taps/homebrew/homebrew-core/Formula
git checkout -b icu4c-70 aa997d1c221d249325e56c238acb90ef7b4e0fc9
brew reinstall ./icu4c.rb
brew list icu4c
git checkout master
mkdir /usr/local/opt/icu4c
cp -rf /usr/local/Cellar/icu4c/70.1/** /usr/local/opt/icu4c

再次执行php命令就正常了。

Leave a Comment

豫ICP备19001387号-1