dyld:库未加载:/usr/local/opt/icu4c/lib/libicui18n.62.dylib 在 Mac 上使用 brew 安装节点后运行 php 时出错
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/53828891/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
dyld: Library not loaded: /usr/local/opt/icu4c/lib/libicui18n.62.dylib error running php after installing node with brew on Mac
提问by petekaner
I installed node using homebrew (Mojave), afterwards php stoped working and if I try to run php -v
I get this error:
我使用自制软件(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
I tried to uninstall both node and icu4c but the problem persists
我尝试卸载 node 和 icu4c 但问题仍然存在
回答by TheCodenator
Note- This will upgrade your PHP version.
注意- 这将升级您的 PHP 版本。
I just had this same problem. Upgrading Homebrew and then cleaning up worked for me. This error likely showed up for me because of a mismatch in package versions. None of the above solutions resolved my error, but running the following homebrew commands did.
我刚刚遇到了同样的问题。升级 Homebrew 然后清理对我有用。由于包版本不匹配,我可能会出现此错误。上述解决方案都没有解决我的错误,但运行以下自制命令可以解决。
brew upgrade
Caution- This will upgrade all your brew packages. If you only want to upgrade specific packages make sure to be specific.
注意- 这将升级您的所有 brew 包。如果您只想升级特定的软件包,请确保是特定的。
brew upgrade // for upgrading all packages -- this is the command I used
brew upgrade {package} // for upgrading a specific package
and then
进而
brew cleanup
回答by Grey Black
In my case, that happened because icu4c was upgraded to version 63 but my locally installed postgres image still referenced icu4c 62.1. Therefore i had to change the icu4c version used:
就我而言,发生这种情况是因为 icu4c 已升级到版本 63,但我本地安装的 postgres 映像仍引用 icu4c 62.1。因此,我不得不更改使用的 icu4c 版本:
brew info icu4c
brew switch icu4c <version>
Where version
is the the installed version returned by info
version
返回的安装版本在哪里info
回答by Kevin Elliott
I am actually quite surprised that this solution has not been presented yet, and I feel like it is the easiest solution.
我其实很惊讶这个解决方案还没有提出,我觉得这是最简单的解决方案。
Go to GitHub, find the version of the brewfile that matches the version of icu4c
that you need and get the raw version of the file (follow the links above and click View File
then Raw
).
去GitHub上,找到的版本匹配的brewfile的版本icu4c
,你需要和获取文件的原始版本(按照上面的链接,点击View File
然后Raw
)。
Then just have brew reinstall from that url.
然后只需从该网址重新安装 brew 即可。
For example, version 62.1
:
例如,版本62.1
:
brew reinstall https://raw.githubusercontent.com/Homebrew/homebrew-core/575eb4bbef683551e19f329f60456b13a558132f/Formula/icu4c.rb
For example, version 64.2
:
例如,版本64.2
:
brew reinstall https://raw.githubusercontent.com/Homebrew/homebrew-core/a806a621ed3722fb580a58000fb274a2f2d86a6d/Formula/icu4c.rb
回答by Leland
Turns out I, like @Grey Black, had to actually install v62.1 of icu4c. Nothing else worked.
结果我和@Grey Black 一样,不得不实际安装 icu4c 的 v62.1。没有其他工作。
However, brew switch icu4c 62.1
only works if you have installed 62.1 in the past. If you haven't there's more legwork involved. Homebrew does not make it easy to installprevious versions of formulae.
但是,brew switch icu4c 62.1
只有在您过去安装过 62.1 时才有效。如果你还没有涉及更多的跑腿工作。Homebrew无法轻松安装以前版本的公式。
Here's how I did it:
这是我如何做到的:
- 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.
- 我们首先需要对 Homebrew 存储库进行深度克隆。可能还要等一下:
git -C $(brew --repo homebrew/core) fetch --unshallow
brew log icu4c
追踪引用 62.1 的提交;575eb4b
诀窍。cd $(brew --repo homebrew/core)
git checkout 575eb4b -- Formula/icu4c.rb
brew uninstall --ignore-dependencies icu4c
brew install icu4c
您现在应该拥有正确版本的依赖项!现在只是为了...git reset && git checkout .
清理修改后的配方。
回答by Arun Karnati
I had the same problem after I upgraded my macOS
to version 10.13.6
. I can't run composer
and php
commands. After researching for a while and trying various solutions posted online, reinstalling php using homebrew
worked.
升级macOS
到版本后我遇到了同样的问题10.13.6
。我不能运行composer
和php
命令。在研究了一段时间并尝试了在线发布的各种解决方案后,使用homebrew
工作重新安装 php 。
brew reinstall [email protected]
brew reinstall [email protected]
Added on March 14th based on Ryan's comment
根据 Ryan 的评论于 3 月 14 日添加
get the version you are currently using by running php -v
and get the right formulae (which you can find here: https://formulae.brew.sh/formula/php) to replace @7.1
in the above command.
通过运行php -v
获取您当前使用的版本并获取正确的公式(您可以在此处找到:https: //formulae.brew.sh/formula/php)以替换@7.1
上述命令。
回答by Lucas Bustamante
Run npm version
and see if you see the same error.
运行npm version
,看看你是否看到同样的错误。
If so, upgrade your npm version brew upgrade npm
.
如果是这样,请升级您的 npm 版本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
回答by serdarsenay
This fixed it for me:
这为我修复了它:
brew upgrade node
回答by glajan
Just brew remove php
and brew install php
did not work, nor did brew reinstall php
.
My solution was to do:
只是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
Now php -v
gives me:
现在php -v
给我:
PHP 7.3.2 (cli) (built: Feb 14 2019 10:08:45) ( NTS )
回答by Serhey Dolgushev
Seems like it is impossible to link icu4c
using brew
after latest OS X update. Which makes things more interesting. The only solution I found working for me:
似乎在最新的 OS X 更新后无法链接icu4c
使用brew
。这让事情变得更有趣。我发现对我有用的唯一解决方案:
- Download and compile
icu4c
62.1 to/usr/local/icu4c/62.1
- 下载并编译
icu4c
62.1 到/usr/local/icu4c/62.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
- Link libs:
- 链接库:
ln -s /usr/local/icu4c/62.1/lib/*.dylib /usr/local/include/
- Set
DYLD_LIBRARY_PATH
in~/.bash_profile
:
- 设置
DYLD_LIBRARY_PATH
在~/.bash_profile
:
export DYLD_LIBRARY_PATH=/usr/local/include
回答by Matt Rink
I had problems because my version of PHP (7.3) was expecting icu4c 63 and brew would only install 64.
我遇到了问题,因为我的 PHP (7.3) 版本期望 icu4c 63,而 brew 只会安装 64。
https://stackoverflow.com/a/55828190/2000947helped me install 63.