我使用自制(Mojave)安装节点,之后php停止工作,如果我尝试运行php -v,我会得到这个错误:
php -v
dyld: Library not loaded: /usr/local/opt/icu4c/lib/libicui18n.62.dylib
Referenced from: /usr/local/bin/php
Reason: image not found
我尝试卸载node和icu4c,但问题仍然存在
我使用自制(Mojave)安装节点,之后php停止工作,如果我尝试运行php -v,我会得到这个错误:
php -v
dyld: Library not loaded: /usr/local/opt/icu4c/lib/libicui18n.62.dylib
Referenced from: /usr/local/bin/php
Reason: image not found
我尝试卸载node和icu4c,但问题仍然存在
当前回答
实际上,我直接在自制网页上找到了解决方案:https://docs.brew.sh/Common-Issues
升级macOS会导致以下错误:
/usr/local/opt/icu4c/lib/libicui18n.54.dylib:库未加载 配置错误:不能找到libz 在macOS升级后,可能需要重新安装Xcode命令行工具并酿造升级所有已安装的公式:
xcode-select --install
brew upgrade
在我的案例中,问题与升级操作系统无关,但解决方案很有效。
其他回答
在我的情况下,我不得不在两个版本的icu4c之间切换,因为我仍然维护PHP 5.6项目(使用旧的icu4c 64.2)。由于某些原因,从原始.rb链接进行安装和重新安装总是会替换以前安装的版本。
#fetching 64.2
brew fetch https://raw.githubusercontent.com/Homebrew/homebrew-core/a806a621ed3722fb580a58000fb274a2f2d86a6d/Formula/icu4c.rb
#fetching stable version
brew fetch https://raw.githubusercontent.com/Homebrew/homebrew-core/master/Formula/icu4c.rb
cd $(brew --cache)/downloads
tar xvfz e2a83648f37dc5193016ce14fa6faeb97460258b214e805b1d7ce8956e83c1a7--icu4c-64.2.catalina.bottle.tar.gz
tar xvfz e045a709e2e21df31e66144a637f0c77dfc154f60183c89e6b04afa2fbda28ba--icu4c-67.1.catalina.bottle.tar.gz
mv -n icu4c/67.1 $(brew --cellar)/icu4c/
mv -n icu4c/64.2 $(brew --cellar)/icu4c/
然后在版本之间切换
$ brew switch icu4c 64.2
Cleaning /usr/local/Cellar/icu4c/64.2
Cleaning /usr/local/Cellar/icu4c/67.1
Opt link created for /usr/local/Cellar/icu4c/64.2
$ brew switch icu4c 67.1
Cleaning /usr/local/Cellar/icu4c/64.2
Cleaning /usr/local/Cellar/icu4c/67.1
Opt link created for /usr/local/Cellar/icu4c/67.1
在我的情况下,酿造更新icu4c到版本67.1,所以我的php7.1不能工作。 重新安装icu4c就可以了。
参考:https://devhoi.com/threads/error-dyld-library-not-loaded-usr-local-opt-icu4c-lib-libicui18n-64-dylib-with-php7-1.26/
结果我和@Grey Black一样,不得不安装icu4c的v62.1版本。其他方法都不管用。
但是,酿造开关icu4c 62.1仅在过去安装过62.1的情况下才能工作。如果你还没有,就需要做更多跑腿的工作。Homebrew不容易安装以前版本的公式。
我是这样做的:
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
如果你决定在某个时候升级它,一定要运行brew unpin icu4c
在我的例子中,发生这种情况是因为icu4c升级到版本63,但我在本地安装的postgres映像仍然引用icu4c 62.1。因此,我不得不改变使用的icu4c版本:
brew info icu4c
brew switch icu4c <version>
其中version是info返回的已安装版本。
对我来说,brew重装nodejs修复了这个问题-我的问题是运行Elixir/Phoenix,所以不是PHP特定的,我认为这是由brew安装postgres引起的,但重新安装没有帮助。我从npm命令中得到它。