我使用自制(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,但问题仍然存在
当前回答
2021-02简单解决方案
在处理这个问题多年后,下面的解决方案对我来说非常简单:
在您需要的版本的web浏览器中打开原始文件:
版本62:https://raw.githubusercontent.com/Homebrew/homebrew-core/575eb4bbef683551e19f329f60456b13a558132f/Formula/icu4c.rb
版本64:https://raw.githubusercontent.com/Homebrew/homebrew-core/a806a621ed3722fb580a58000fb274a2f2d86a6d/Formula/icu4c.rb
版本66:https://raw.githubusercontent.com/Homebrew/homebrew-core/22fb699a417093cd1440857134c530f1e3794f7d/Formula/icu4c.rb
版本67:https://raw.githubusercontent.com/Homebrew/homebrew-core/88b9cc789820f2f544d8d4a1053eebb044c2926c/Formula/icu4c.rb
最新版本:https://raw.githubusercontent.com/Homebrew/homebrew-core/master/Formula/icu4c.rb
复制粘贴内容到一个名为: icu4c.rb 在新创建的文件上执行以下命令
来源:https://gist.github.com/hgrimelid/703691ab48c4a4d0537cfe835b4d55a6
其他回答
在MacOS Mojave上,我唯一能修复它的方法是brew升级
在OSX 10.15.4上运行xcode-select——install修复了这个问题。
在我的情况下,酿造更新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/
我把macOS升级到10.13.6版本后也遇到了同样的问题。我不能运行composer和php命令。在研究了一段时间并尝试了网上发布的各种解决方案后,使用homebrew重新安装php成功了。
酿造重新安装php@7.1
3月14日根据Ryan的评论添加的
通过运行PHP -v获取当前使用的版本,并获得正确的公式(可以在这里找到:https://formulae.brew.sh/formula/php)来替换上面命令中的@7.1。
Leland的答案对我来说很管用,但我不得不把第4步和第6步改为:
4) git checkout -B icu4c-62.1 575eb4b
6) brew重装Formula/icu4c.rb