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
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:
Where
version
is the the installed version returned byinfo
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.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.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.
and then
On MacOS Mojave, only way I could fix it was with
brew upgrade
For me
brew reinstall nodejs
fixed this - my issue was with running Elixir/Phoenix so not PHP specific, I think it was caused bybrew install postgres
, but reinstalling that didn't help. I was getting it fromnpm
commands.Just
brew remove php
andbrew install php
did not work, nor didbrew reinstall php
. My solution was to do:Now
php -v
gives me: