dyld: Library not loaded: /usr/local/opt/icu4c/lib

2020-01-29 03:37发布

I installed node using homebrew (Mojave), afterwards php stoped working and if I try to run php -v I get this error:

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

17条回答
欢心
2楼-- · 2020-01-29 03:42

Run npm version and see if you see the same error.

If so, upgrade your node 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

Credits

查看更多
祖国的老花朵
3楼-- · 2020-01-29 03:44

Got this error, too, after installing php 7.3. I had it resolved upgrading just my old php's versions (5.6 and 7.0, not from the official repos).

The maintainers had compiled new php versions against the current icu4c.

In my case, PHP 7 got from 0.31 to 0.33, and the problem was solved.

查看更多
倾城 Initia
4楼-- · 2020-01-29 03:45

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.

brew reinstall php@7.1

Added on March 14th based on Ryan's comment

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.

查看更多
太酷不给撩
5楼-- · 2020-01-29 03:45

Leland's answer worked for me, but I had to change steps 4 and 6 to:

4) git checkout -B icu4c-62.1 575eb4b

6) brew reinstall Formula/icu4c.rb

查看更多
爱情/是我丢掉的垃圾
6楼-- · 2020-01-29 03:46

I had problems because my version of PHP (7.3) was expecting icu4c 63 and brew would only install 64.

https://stackoverflow.com/a/55828190/2000947 helped me install 63.

查看更多
趁早两清
7楼-- · 2020-01-29 03:48

In order to downgrade, i had to recompile from source (MacOS Mojave)

$ 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
查看更多
登录 后发表回答