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


当前回答

我的问题:

# npm install -g canvas

dyld: Library not loaded: /usr/local/opt/icu4c/lib/libicui18n.64.dylib
  Referenced from: /usr/local/opt/node@8/bin/node
  Reason: image not found

现在20210118,经过多次尝试:

...
brew reinstall https://raw.githubusercontent.com/Homebrew/homebrew-core/master/Formula/icu4c.rb
brew upgrade npm
brew install node
brew uninstall --ignore-dependencies node@8 icu4c
brew install icu4c
...

最终解决方案为:

重新安装NPM

其他回答

我实际上尝试了所有有意义的解决方案,在这篇文章中提到的,但我仍然在运行php -v或composer时得到相同的错误。 节点版本很好,npm也没有安装正确版本的问题,它们都在运行。 运行重新安装php@7.1会抛出一个错误。 最后我不得不逃跑:

brew reinstall icu4c

这基本上是可行的,我必须手动安装php依赖项,如imagick。所以,imap.so 由于这些库是为一个我不再维护的项目安装的,我可以没有它们。但如果你确实依赖他们,请记住,之后会有更多的工作要做。

我只是想留下一个关于当前如何修复这个问题的详细总结(这对我来说很有效):

首先去本地安装自制软件

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

我的问题:

# npm install -g canvas

dyld: Library not loaded: /usr/local/opt/icu4c/lib/libicui18n.64.dylib
  Referenced from: /usr/local/opt/node@8/bin/node
  Reason: image not found

现在20210118,经过多次尝试:

...
brew reinstall https://raw.githubusercontent.com/Homebrew/homebrew-core/master/Formula/icu4c.rb
brew upgrade npm
brew install node
brew uninstall --ignore-dependencies node@8 icu4c
brew install icu4c
...

最终解决方案为:

重新安装NPM

关于恢复icu4c丢失版本有很多答案。我在postgresql中也有同样的错误,我想这可以在依赖于动态链接该库的各种程序中体现出来。

对于我来说,我使用的是特定版本的postgresql,即postgresql@12。我发现最简单的方法就是重新安装

brew reinstall postgresql@12

我想这也适用于php。

我已经尝试了这里的许多建议,最后酿造升级php是对我有用的,但似乎这个问题无处不在