Library not loaded error after brew install php56

2020-03-13 08:18发布

问题:

I'm upgrading from php5.5 to php5.6 on OSX Mavericks using homebrew. I run

brew install php56

Everything runs and completes fine but when I run php -v the following error comes up

dyld: Library not loaded: /usr/local/opt/icu4c/lib/libicui18n.53.dylib
Referenced from: /usr/local/bin/php
Reason: image not found
Trace/BPT trap: 5

How do I fix this?

回答1:

Try this

brew uninstall --ignore-dependencies node icu4c
brew install node


回答2:

For me simply upgrading php helped.

brew upgrade php

The corresponding file dyld: Library not loaded: /usr/local/opt/icu4c/lib/libicui18n.<version>.dylib did not exist but a more recent one. So my php version was a bit behind compared to other dependents which probably upgraded icu4c when upgrading them. (Either node or postgresql?)



回答3:

In my case, it was a symlink issue with the previous installation. Everything was fine after running

brew link --overwrite php56

P.S. Before running with --overwrite, try without. If you get the error below like I did, then go ahead.

Linking /usr/local/Cellar/php56/5.6.3...
Error: Could not symlink bin/pear
Target /usr/local/bin/pear
is a symlink belonging to php55. You can unlink it:
  brew unlink php55

To force the link and overwrite all conflicting files:
  brew link --overwrite php56

To list all files that would be deleted:
  brew link --overwrite --dry-run php56


回答4:

previous solution was not working:

$ php -i
dyld: Library not loaded: /usr/local/opt/icu4c/lib/libicui18n.55.dylib
  Referenced from: /usr/local/bin/php
  Reason: image not found
Trace/BPT trap: 5

solved with:

$ brew update && brew upgrade icu4c

see https://github.com/Homebrew/homebrew-php/issues/1701



回答5:

dyld: Library not loaded: /usr/local/opt/icu4c/lib/libicui18n.53.dylib

It sounds like an issue with icu4c. So try:

brew uninstall icu4c && brew install icu4c
brew unlink icu4c && brew link icu4c --force

In case of further issues, investigate them by brew doctor.



回答6:

For this to be fixed for me (Mavericks 10.9.5) necessitated the entire routine described in this GitHub issue, namely:

brew uninstall --force php56

brew update

brew tap --repair

find $(brew --cache) -mindepth 1 -print -delete

brew install -v php56

(and in my case I needed brew install php56-mcrypt as well, as that was missing.)

I'd had PHP 5.4 and 5.6 installed before, with 5.4 being the active ("linked") one – I wanted to switch. I'd installed the php-switcher package, which is a very neat way of letting you do this, but it wasn't working prior to the above procedure.



回答7:

brew uninstall --ignore-dependencies node icu4c
brew install node

worked for me.