我使用自制(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,但问题仍然存在


当前回答

结果我和@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升级到10.13.6版本后也遇到了同样的问题。我不能运行composer和php命令。在研究了一段时间并尝试了网上发布的各种解决方案后,使用homebrew重新安装php成功了。

酿造重新安装php@7.1

3月14日根据Ryan的评论添加的

通过运行PHP -v获取当前使用的版本,并获得正确的公式(可以在这里找到:https://formulae.brew.sh/formula/php)来替换上面命令中的@7.1。

实际上,我直接在自制网页上找到了解决方案:https://docs.brew.sh/Common-Issues

升级macOS会导致以下错误:

/usr/local/opt/icu4c/lib/libicui18n.54.dylib:库未加载 配置错误:不能找到libz 在macOS升级后,可能需要重新安装Xcode命令行工具并酿造升级所有已安装的公式:

xcode-select --install
brew upgrade

在我的案例中,问题与升级操作系统无关,但解决方案很有效。

在我的情况下,我重新安装与Homebrew安装的所有包

$ brew list | xargs brew reinstall

之后,我开始安装我需要的版本

如果你有最新的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时消失,但这可能是最快的修复方法。

我看了这篇文章,这似乎是我所缺少的一块拼图:

brew uninstall node@8