Skip to content

Instantly share code, notes, and snippets.

@hgrimelid
Created August 17, 2018 07:36
Show Gist options
  • Star 13 You must be signed in to star a gist
  • Fork 4 You must be signed in to fork a gist
  • Save hgrimelid/703691ab48c4a4d0537cfe835b4d55a6 to your computer and use it in GitHub Desktop.
Save hgrimelid/703691ab48c4a4d0537cfe835b4d55a6 to your computer and use it in GitHub Desktop.
php: Library not loaded: /usr/local/opt/icu4c/lib/libicui18n.61.dylib

After upgrading to Node v.10.9.0 via Homebrew the following error message was thrown from PHP:

dyld: Library not loaded: /usr/local/opt/icu4c/lib/libicui18n.61.dylib
  Referenced from: /usr/local/bin/php
  Reason: image not found

Reinstall PHP to fix, for me that's:

brew reinstall php@7.1

@Ardakilic
Copy link

Ardakilic commented Feb 10, 2021

Update Hopefully now I have a proper solution for this. @jv2222 you should also check this:

Icu4c reinstallation made me force reinstall PHP8, which broke the purpose for me. So, I have found some new repositories where you don't need to hassle with this icu4c stuff at all:

brew install shivammathur/php/php@5.6
brew install shivammathur/php/php@7.0
brew install shivammathur/php/php@7.1
brew install shivammathur/php/php@7.2
brew install shivammathur/php/php@7.3
brew install shivammathur/php/php@7.4
brew install shivammathur/php/php@8.0

First, delete all php installations with a command something like brew uninstall "php*" and brew unlink php@7.1

You may also need to untap other taps. I had to run

brew untap exolnet/deprecated

to install properly.

Then, if you want, delete the /usr/local/etc/php folder

then install one of the packages I've linked above.

Worked Nicely for PHP 7.1:

➜  ~ php -v
PHP 7.1.33 (cli) (built: Dec  1 2020 01:14:43) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.1.0, Copyright (c) 1998-2018 Zend Technologies
    with Zend OPcache v7.1.33, Copyright (c) 1999-2018, by Zend Technologies

You can also quickly switch between php versions with a command like:

brew unlink php && brew link --overwrite --force php@7.2

etc.

The GitHub repository: https://github.com/shivammathur/homebrew-php

The source where I found these packages: here.

I also shared this answer back here in SO: https://stackoverflow.com/questions/60128044/error-while-installing-php-7-1-for-mac-with-homebrew/65438579#65438579

@ninjachen
Copy link

In my case, reinstallation php@7.1 didn't work. I downgrade the icu4c from 67 to 64 by this document

@EdieLemoine
Copy link

@Ardakilic Thank you, your solution worked for me on MacOS 11.2.2.

@Ardakilic
Copy link

@EdieLemoine glad that helped. I've been using that very repository for PHP7.1-7.4 over the time, without issues.

@gonzalogcontacto
Copy link

brew reinstall php@[YOUR_VERSION] is working 👍

@joneiros
Copy link

joneiros commented May 6, 2021

PHP@7.3 (PHP 7.3.28)
Initial suggestion of PHP reinstall worked!

Error:

dyld: Library not loaded: /usr/local/opt/icu4c/lib/libicui18n.68.dylib
  Referenced from: /usr/local/opt/php@7.3/bin/php
  Reason: image not found

Caused by: icu4c updated to 69.1 from another brew install.

Solution: brew reinstall php@7.3

Thank you OP!

@saw-gain
Copy link

saw-gain commented May 18, 2021

Hi,
I am getting this warning when installing the php on macOS Big sur

  dyld: Library not loaded: /usr/local/opt/openldap/lib/libldap-2.5.0.dylib
  Referenced from: /usr/local/Cellar/php/8.0.6/bin/php
  Reason: image not found

brew reinstalling did not work. Can anyone please help?

thank you!

@Ardakilic
Copy link

@saw-gain please check my comment here. I've been using these packages without issues.

@vamaship-saud-qureshi
Copy link

vamaship-saud-qureshi commented Jun 9, 2022

Update Hopefully now I have a proper solution for this. @jv2222 you should also check this:

Icu4c reinstallation made me force reinstall PHP8, which broke the purpose for me. So, I have found some new repositories where you don't need to hassle with this icu4c stuff at all:

brew install shivammathur/php/php@5.6
brew install shivammathur/php/php@7.0
brew install shivammathur/php/php@7.1
brew install shivammathur/php/php@7.2
brew install shivammathur/php/php@7.3
brew install shivammathur/php/php@7.4
brew install shivammathur/php/php@8.0

First, delete all php installations with a command something like brew uninstall "php*" and brew unlink php@7.1

You may also need to untap other taps. I had to run

brew untap exolnet/deprecated

to install properly.

Then, if you want, delete the /usr/local/etc/php folder

then install one of the packages I've linked above.

Worked Nicely for PHP 7.1:

➜  ~ php -v
PHP 7.1.33 (cli) (built: Dec  1 2020 01:14:43) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.1.0, Copyright (c) 1998-2018 Zend Technologies
    with Zend OPcache v7.1.33, Copyright (c) 1999-2018, by Zend Technologies

You can also quickly switch between php versions with a command like:

brew unlink php && brew link --overwrite --force php@7.2

etc.

The GitHub repository: https://github.com/shivammathur/homebrew-php

The source where I found these packages: here.

I also shared this answer back here in SO: https://stackoverflow.com/questions/60128044/error-while-installing-php-7-1-for-mac-with-homebrew/65438579#65438579

@Ardakilic
Thanks a lot man.
This was helpful

@sid3r
Copy link

sid3r commented Sep 19, 2023

Reinstalling and compiling from source fixed the issue for me

brew reinstall --build-from-source php

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment