dyld:未加载库:/usr/local/opt/icu4c/lib/libicui18n.62.dylib在Mac上安装brew节点后运行php时出错

问题描述 投票:121回答:12

我使用自制程序(Mojave)安装节点,之后php停止工作,如果我尝试运行qazxsw poi,我收到此错误:

php -v

我试图卸载节点和icu4c,但问题仍然存在

php node.js macos homebrew
12个回答
185
投票

在我的情况下,发生这种情况是因为icu4c升级到版本63但我在本地安装的postgres图像仍然引用了icu4c 62.1。因此我不得不改变使用的icu4c版本:

php -v
dyld: Library not loaded: /usr/local/opt/icu4c/lib/libicui18n.62.dylib
  Referenced from: /usr/local/bin/php
  Reason: image not found

其中 brew info icu4c brew switch icu4c <version> version返回的已安装版本


1
投票

Leland的回答对我有用,但我不得不将步骤4和6更改为:

4)git checkout -B icu4c-62.1 575eb4b

6)brew重新安装Formula / icu4c.rb


1
投票

我有问题,因为我的PHP版本(7.3)期待icu4c 63和brew只会安装64。

export DYLD_LIBRARY_PATH=/usr/local/include 帮我安装了63。


0
投票

安装php 7.3之后也出现了这个错误。我解决了升级只是我旧的PHP的版本(5.6和7.0,而不是官方的回购)。

维护者已针对当前的icu4c编译了新的php版本。

就我而言,PHP 7从0.31增加到0.33,问题解决了。


0
投票

为了降级,我不得不从源代码重新编译(MacOS Mojave)

https://stackoverflow.com/a/55828190/2000947

0
投票

这为我修好了:

$ wget https://ssl.icu-project.org/files/icu4c/62.1/icu4c-62_1-src.tgz
$ tar xvfz icu4c-62_1-src.tgz
$ cd icu/sources
$ ./configure
$ make
$ make install

196
投票

注意 - 这将升级您的PHP版本。

我刚遇到同样的问题。升级Homebrew然后清理为我工作。由于软件包版本不匹配,我可能会出现此错误。上述解决方案都没有解决我的错误。

info

注意 - 这将升级所有brew包。如果您只想升级特定的包,请确保具体。

brew upgrade

然后

brew upgrade {package}

45
投票

事实证明,我和@Grey Black一样,必须安装v62.1的icu4c。没有其他工作。

但是,brew cleanup 仅在您过去安装了62.1时才有效。如果你没有涉及更多的腿部工作。 Homebrew做brew switch icu4c 62.1以前版本的公式。

我是这样做的:

  1. 我们首先需要深度克隆Homebrew仓库。这可能需要一段时间:not make it easy to install
  2. git -C $(brew --repo homebrew/core) fetch --unshallow用于追踪引用62.1的提交; brew log icu4c做到了这一点。
  3. 575eb4b
  4. cd $(brew --repo homebrew/core)
  5. git checkout 575eb4b -- Formula/icu4c.rb
  6. brew uninstall --ignore-dependencies icu4c您现在应该拥有正确的依赖版本!现在只是......
  7. brew install icu4c清理你修改过的食谱。

添加了几个额外的笔记,感谢@Noah的捕获


31
投票

我将git reset && git checkout .升级到版本macOS之后我遇到了同样的问题。我无法运行10.13.6composer命令。经过一段时间的研究并尝试在线发布的各种解决方案,使用php重新安装php工作。

homebrew

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

通过运行brew reinstall [email protected]得到你当前正在使用的版本并获得正确的公式(你可以在这里找到:php -v)来替换上面命令中的https://formulae.brew.sh/formula/php


15
投票

运行@7.1并查看是否看到相同的错误。

如果是这样,请升级您的节点版本npm version

brew upgrade npm

==> Upgrading 1 outdated package, with result: npm 8.1.2 -> 10.3.0 ==> Upgrading npm ==> Installing dependencies for node: icu4c ==> Installing node dependency: icu4c


12
投票

我真的很惊讶这个解决方案尚未提出,我觉得这是最简单的解决方案。

转到GitHub,找到与您需要的Credits版本匹配的brewfile版本,并获取该文件的原始版本(按照上面的链接,然后单击icu4c,然后单击View File)。

然后从该网址重新安装brew。

例如,版本Raw

62.1

4
投票

只是brew reinstall https://raw.githubusercontent.com/Homebrew/homebrew-core/575eb4bbef683551e19f329f60456b13a558132f/Formula/icu4c.rb brew remove php没有工作,brew install php也没有。我的解决方案是:

brew reinstall php

现在brew remove php cd /usr/local/Cellar rm -rf php/ brew install php brew doctor brew cleanup 给了我:

php -v

1
投票

而不是安装较旧的(预编译的)php可以链接到的旧版本的PHP 7.3.2 (cli) (built: Feb 14 2019 10:08:45) ( NTS ) ,最好重新编译旧的PHP以链接到更新的库。

icu4c

这将构建php并将其链接到较新的库。我发现brew uninstall [email protected] brew install --build-from-source [email protected] 不太起作用;目标文件夹已存在时,新安装会被阻塞。

我也为我的环境做了reinstall


1
投票

似乎在最新的OS X更新后使用brew link --force [email protected]链接icu4c是不可能的。这让事情变得更有趣。我发现为我工作的唯一解决方案:

  1. 下载并编译brew 62.1到icu4c
/usr/local/icu4c/62.1
  1. 链接库:
mkdir ~/sources
cd ~/sources
wget http://download.icu-project.org/files/icu4c/62.1/icu4c-62_1-src.tgz
tar xvzf icu4c-62_1-src.tgz
cd icu/source/

sudo mkdir /usr/local/icu4c/62.1
./configure --prefix=/usr/local/icu4c/62.1
make
sudo make install
  1. ln -s /usr/local/icu4c/62.1/lib/*.dylib /usr/local/include/ 中设置DYLD_LIBRARY_PATH
~/.bash_profile

希望它能节省几个小时的时间。

© www.soinside.com 2019 - 2024. All rights reserved.