我使用自制(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,但问题仍然存在
当前回答
这为我解决了问题:
brew upgrade node
其他回答
在安装php 7.3后也得到这个错误。我已经解决了升级旧的php版本(5.6和7.0,不是从官方回购)。
维护者根据当前的icu4c编译了新的php版本。
在我的例子中,PHP 7从0.31升级到0.33,问题得到了解决。
关于恢复icu4c丢失版本有很多答案。我在postgresql中也有同样的错误,我想这可以在依赖于动态链接该库的各种程序中体现出来。
对于我来说,我使用的是特定版本的postgresql,即postgresql@12。我发现最简单的方法就是重新安装
brew reinstall postgresql@12
我想这也适用于php。
结果我和@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
在MacOS Mojave上,我唯一能修复它的方法是brew升级
我只是想留下一个关于当前如何修复这个问题的详细总结(这对我来说很有效):
首先去本地安装自制软件
cd /usr/local/Homebrew/
Homebrew > 2.5删除了直接从git回购中安装公式的选项,所以我们需要签出一个旧版本
git checkout 2.3.0
安装icu4c版本(在我的情况下,64.2与php@7.1兼容)
HOMEBREW_NO_AUTO_UPDATE=1 brew install https://raw.githubusercontent.com/Homebrew/homebrew-core/a806a621ed3722fb580a58000fb274a2f2d86a6d/Formula/icu4c.rb
回到当前版本的自制
git checkout -
告诉brew使用旧版本的icu4c,这样如果你已经安装了两个版本,你可以选择使用哪个版本
brew switch icu4c 64.2