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
Run
npm version
and see if you see the same error.If so, upgrade your node version
brew upgrade npm
.Credits
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.
I had the same problem after I upgraded my
macOS
to version10.13.6
. I can't runcomposer
andphp
commands. After researching for a while and trying various solutions posted online, reinstalling php usinghomebrew
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.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
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.
In order to downgrade, i had to recompile from source (MacOS Mojave)