我使用自制(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,但问题仍然存在
当前回答
[2020]版
对我来说,就是用所需的版本安装icu4c。
如果你需要安装旧版本,如版本62,(其他版本相同的步骤),你需要:
用这个版本创建自己的repo(或找别人的repo) Brew tap(每个版本的链接都不同):
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
yourUsername / homebrew-versions /公式/ 将下载的文件放入“公式”文件夹 brew tap [yourUsername]/homebrew-versions brew install [yourUsername]/homebrew-versions/icu4c .使用实例 你说对了!
其中[yourUsername]是您的GitHub帐户或已经拥有所需版本的人的名称。
Unfortunately, latest homebrew gives no longer a warning and now displays the error: Error: Calling Installation of XXX from a GitHub commit URL is disabled! Use 'brew extract XXX' to stable tap on GitHub instead. So the way to go now is to create a new repo on github called homebrew-versions to host the Formula in a Tap Then initialise it with: brew tap-new MYORG/homebrew-versions after git cloning the homebrew repo as suggested by Shine Hugh, copy paste the raw ruby file to your new Formula. Beware the funny naming convention! Example: File name is: gettext@0.20.2.rb Class name is: GettextAT0202 Example: https://github.com/nedap/homebrew-versions source:https://itnext.io/how-to-install-an-older-brew-package-add141e58d32
其他回答
我把macOS升级到10.13.6版本后也遇到了同样的问题。我不能运行composer和php命令。在研究了一段时间并尝试了网上发布的各种解决方案后,使用homebrew重新安装php成功了。
酿造重新安装php@7.1
3月14日根据Ryan的评论添加的
通过运行PHP -v获取当前使用的版本,并获得正确的公式(可以在这里找到:https://formulae.brew.sh/formula/php)来替换上面命令中的@7.1。
我只是想留下一个关于当前如何修复这个问题的详细总结(这对我来说很有效):
首先去本地安装自制软件
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
如果你有最新的icu4c版本,并且像我一样遭受软件脆弱的折磨,只想让postgres/任何东西工作:
$ brew upgrade icu4c
Warning: icu4c 69.1 already installed
然后你可以创建符号链接:
> dyld: Library not loaded: /usr/local/opt/icu4c/lib/libicuuc.68.dylib
cd /usr/local/opt/icu4c/lib
ln -s libicuuc.69.1.dylib libicuuc.68.dylib
ln -s libicuio.69.1.dylib libicui18n.68.dylib
这些符号链接将在您第一次更新icu4c时消失,但这可能是最快的修复方法。
在我的情况下,酿造更新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/
Brew update && Brew upgrade对我来说很有效