Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

dyld: Library not loaded: /usr/local/opt/icu4c/lib/libicui18n.62.dylib error running php after installing node with brew on Mac

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

like image 347
petekaner Avatar asked Dec 18 '18 08:12

petekaner


2 Answers

Update - As stated in some of the comments, running brew cleanup could possibly fix this error, if that alone doesn't fix it, you might try upgrading individual packages or all your brew packages.

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.

Caution - This will upgrade all your brew packages, including, but not limited to PHP. If you only want to upgrade specific packages make sure to be specific.

brew upgrade icu4c

brew upgrade // or upgrade all packages

and finally

brew cleanup
like image 160
Vim Diesel Avatar answered Nov 06 '22 13:11

Vim Diesel


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 installed version returned by info.

like image 322
Grey Black Avatar answered Nov 06 '22 15:11

Grey Black