dyld: Library not loaded: /usr/local/opt/icu4c/lib/libicui18n.62.dylib error running php after installing node with brew on Mac

✔ Recommended Answer

Update - As stated in some of the comments, running brew cleanup could possibly fix this error, if that alone doesn't fix it, you might try upgrading individual packages or all your brew packages.

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.

Caution - This will upgrade all your brew packages, including, but not limited to PHP. If you only want to upgrade specific packages make sure to be specific.

brew upgrade icu4cbrew upgrade // or upgrade all packages

and finally

brew cleanup
Method #2

This error can occur on a Mac when you install Node.js using Homebrew and it upgrades the ICU library used by PHP. The upgraded ICU library may not be compatible with your version of PHP, causing the dyld: Library not loaded error when running PHP.

To resolve this issue, you can try one of the following solutions:

  1. Reinstall PHP: You can try reinstalling PHP using Homebrew to ensure that it is compatible with the upgraded ICU library. You can do this by running the following command:

    brew reinstall php

    This will reinstall the latest version of PHP available from Homebrew.

  2. Link the old ICU library: If you don't want to reinstall PHP, you can try linking the old ICU library used by PHP before the upgrade. To do this, you can run the following commands:

    brew unlink icu4c brew install https://raw.githubusercontent.com/Homebrew/homebrew-core/c80b5d5a91a7a902f9cc634b34e064433605a2e7/Formula/icu4c.rb

    This will unlink the upgraded ICU library and install the old ICU library that was used by PHP before the upgrade. Note that this approach may cause compatibility issues with other applications that require the upgraded ICU library.

  3. Downgrade Node.js: If you don't need the latest version of Node.js, you can try downgrading it to a version that is compatible with your version of PHP. You can do this by running the following command:

    brew install node@10

    This will install Node.js version 10, which is known to be compatible with some older versions of PHP.

Once you have tried one of these solutions, you can try running PHP again to see if the issue has been resolved.


Most Popular

PhpStorm, return value is expected to be 'A', 'object' returned

Remove Unicode Zero Width Space PHP

Laravel file upload returns forbidden 403, file permission is 700 not 755