系統(tǒng)環(huán)境:macOS Big Sur 11.7
PHP 版本:7.4.33
起因是升級(jí) Mac 系統(tǒng),導(dǎo)致以前安裝配置好的 PHP 版本也升級(jí)了,自己想重新安裝低版本的 PHP 后執(zhí)行 php -v 提示 dyld:Library not load:/usr/local/opt/ icu4c/lib/libicuio.71.dylib

Md Lieeey rot Loodedfusenecaloettcutcntbntbtcuto.71.dy1t6.png
其實(shí)就是 php 版本與 icu4c 這個(gè)擴(kuò)展庫(kù)版本不兼容了,以下內(nèi)容引用自 stackoverflow 一位博主解答,親測(cè)有效。其大致思路就是去 icu4c 這個(gè)擴(kuò)展的 git 提交歷史 log 中重新檢出低版本的,然后鎖定當(dāng)前版本,確保不會(huì)被 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 icu4cto track down a commit that references 62.1;575eb4bdoes the trick. cd $(brew --repo homebrew/core)git checkout 575eb4b -- Formula/icu4c.rbbrew uninstall --ignore-dependencies icu4c-
brew install icu4cYou should now have the correct version of the dependency! Now just to... -
git reset && git checkout .Cleanup your modified recipe. -
brew pin icu4cPin 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