系统环境:macOS Big Sur 11.7
PHP 版本:7.4.33
起因是升级 Mac 系统,导致以前安装配置好的 PHP 版本也升级了,自己想重新安装低版本的 PHP 后执行 php -v
提示 dyld:Library not load:/usr/local/opt/ icu4c/lib/libicuio.71.dylib
Md Lieeey rot Loodedfusenecaloettcutcntbntbtcuto.71.dy1t6.png
其实就是 php 版本与 icu4c 这个扩展库版本不兼容了,以下内容引用自 stackoverflow 一位博主解答,亲测有效。其大致思路就是去 icu4c 这个扩展的 git 提交历史 log 中重新检出低版本的,然后锁定当前版本,确保不会被 brew upgrade 再次更新。
- We first need a deep clone of the Homebrew repo. This may take a while:
git -C $(brew --repo homebrew/core) fetch --unshallow
-
brew log icu4c
to track down a commit that references 62.1;575eb4b
does the trick. cd $(brew --repo homebrew/core)
git checkout 575eb4b -- Formula/icu4c.rb
brew uninstall --ignore-dependencies icu4c
-
brew install icu4c
You should now have the correct version of the dependency! Now just to... -
git reset && git checkout .
Cleanup your modified recipe. -
brew pin icu4c
Pin the dependency to prevent it from being accidentally upgraded in the future
If you decide you do want to upgrade it at some point, make sure to run brew unpin icu4c
参考 stackoverflow @Leland
https://stackoverflow.com/questions/53828891/dyld-library-not-loaded-usr-local-opt-icu4c-lib-libicui18n-62-dylib-error-run