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 lo
Run npm version
, if you see the same error, upgrade npm.
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
Turns out I, like @Grey Black, had to actually install v62.1 of icu4c. Nothing else worked.
However, brew switch icu4c 62.1
only works if you have installed 62.1 in the past. If you haven't there's more legwork involved. Homebrew does not make it easy to install previous versions of formulae.
Here's how I did it:
git -C $(brew --repo homebrew/core) fetch --unshallow
brew log icu4c
to track down a commit that references 62.1; 575eb4b does the trick.cd $(brew --repo homebrew/core)
git checkout 575eb4b -- Formula/icu4c.rb
brew uninstall --ignore-dependencies icu4c
brew install icu4c
You should now have the correct version of the dependency! Now just to...git reset && git checkout .
Cleanup your modified recipe.brew pin icu4c
Pin the dependency to prevent it from being accidentally upgraded in the futureIf you decide you do want to upgrade it at some point, make sure to run brew unpin icu4c
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.
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.
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
brew update && brew upgrade
worked for me