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:53

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:

 brew info icu4c
 brew switch icu4c <version>

Where version is the the installed version returned by info

查看更多
手持菜刀,她持情操
3楼-- · 2020-01-29 03:57

Rather than install an old version of icu4c that the older (precompiled) php can link to, it's better to recompile the old php to link to the more recent library.

brew uninstall php@7.2
brew install --build-from-source php@7.2

This will build php and link it to the newer library. I found reinstall didn't quite work; the new install choked when the destination folder already existed.

I also did brew link --force php@7.2 for my environment.

查看更多
We Are One
4楼-- · 2020-01-29 03:59

Note - This will upgrade your PHP version.

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.

brew upgrade

Caution - This will upgrade all your brew packages. If you only want to upgrade specific packages make sure to be specific.

brew upgrade // for upgrading all packages -- this is the command I used

brew upgrade {package} // for upgrading a specific package

and then

brew cleanup
查看更多
叼着烟拽天下
5楼-- · 2020-01-29 03:59

On MacOS Mojave, only way I could fix it was with brew upgrade

查看更多
The star\"
6楼-- · 2020-01-29 03:59

For me brew reinstall nodejs fixed this - my issue was with running Elixir/Phoenix so not PHP specific, I think it was caused by brew install postgres, but reinstalling that didn't help. I was getting it from npm commands.

查看更多
别忘想泡老子
7楼-- · 2020-01-29 04:04

Just brew remove php and brew install php did not work, nor did brew reinstall php. My solution was to do:

brew remove php
cd /usr/local/Cellar
rm -rf php/
brew install php
brew doctor
brew cleanup

Now php -v gives me:

PHP 7.3.2 (cli) (built: Feb 14 2019 10:08:45) ( NTS )
查看更多
登录 后发表回答