425

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

kqw
  • 17,649
  • 11
  • 61
  • 92
petekaner
  • 5,761
  • 4
  • 24
  • 42
  • Did you also install php from Homebrew? Did you try to reinstall php? – Ortomala Lokni Dec 18 '18 at 20:14
  • 1
    For posterity: uninstall/reinstall yarn/node seems to do the trick. – Nathaniel Ford Feb 14 '19 at 07:31
  • 15
    according to my understanding, this happens when you've mismatch version dependencies. in my case, "brew upgrade" command fixed my issues. please correct me, if i'm wrong in any way. – sh6210 Feb 17 '19 at 14:38
  • While I was getting this, the problem was that `/usr/local/opt/icu4c` didn't exist, and `brew reinstall icu4c` gave me a bunch of "permission denied" issues for the icu4c dir. So I `sudo rm -rf /usr/local/Cellar/icu4c` and `brew reinstall icu4c`, and everything worked. – Seth Johnson Feb 16 '21 at 14:43

32 Answers32

665

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 // for upgrading all packages -- this is the command I used

brew upgrade {package} // for upgrading a specific package

and finally

brew cleanup
Vim Diesel
  • 7,698
  • 1
  • 18
  • 28
  • 68
    That was ...easy – Alan Mar 28 '19 at 11:18
  • This worked for me after running `brew link npm....` command which seems to have borked composer, php, etc. – aubreypwd Apr 17 '19 at 15:05
  • @VincentTang what has npm to do with it? Where did you run this? – evolutionxbox Apr 26 '19 at 09:40
  • 14
    I think this is not a good idea for those that have environment with two versions of PHP like me. Also, brew upgrade will upgrade your PHP version and this is not necessary good if your goal is not to upgrade your PHP, but solve a library error. – mpoletto May 02 '19 at 19:11
  • Good for me! After a Rails problem. – iGian May 27 '19 at 20:59
  • @mpoletto It is a good idea to stay current (for security) and homebrew provides tools to set an older version of one library without putting the entire environment, your users, and your system at risk. If you want to use an older php, it should not come at the cost of throwing the entire system in a time capsule. – Abandoned Cart Jun 07 '19 at 19:58
  • @AbandonedCart I was thinking in a developing environment, only in my machine... Imagine that I have two totally distinct systems in two production environments, one with PHP 5.6 and another with PHP 7.2. I am using my machine to develop sometimes to system 5.6 as another times to 7.2. – mpoletto Jun 11 '19 at 21:01
  • @mpoletto Nothing you have presented is a reason why my suggestion is not possible. You really shouldn't have production systems that are intentionally outdated without good cause. – Abandoned Cart Jun 11 '19 at 22:51
  • Clever but didn't work for me, on the other hand a reinstall of php7.2 also didn't work on my system so that's probably the reason why ... – leo Jun 23 '19 at 09:08
  • 1
    This is the best solution that I've tried so far, the selected answer did not work – Alleo Indong Jul 09 '19 at 01:12
  • 32
    I wouldn't do this because `brew upgrade` will upgrade *all* your brew outdated packages, instead, probably only do `brew upgrade npm` or a specific package, not all. – xgMz Jul 16 '19 at 19:50
  • 2
    @xgMz You’re right about this. For me, I didn’t care if I was updating all my packages, but for someone that doesn’t want to, then that’s probably not great. I added a note to my solution. Thanks! – Vim Diesel Jul 16 '19 at 23:53
  • 1
    @Leland 's answer below is what was needed for me even after brew cleanup and brew upgrade of specific package. Switching the package manually worked. – Vishnu Narang Mar 29 '20 at 19:28
  • 1
    This worked before I even ran brew cleanup. In my case the error didn't occur until I tried running an n98 command (magento cli) through crontab. This helped. – Leo Fisher Apr 16 '20 at 02:47
  • I saw `brew upgrade` and disliked immediately. – tom10271 May 28 '20 at 06:52
  • I did this and ended up with half a day of package cleanup to get my development environment back. Not a good idea for most cases. – Joey Jul 13 '20 at 16:51
  • @Joey I'm sorry to hear that! I know this solution helped me and has helped others. If there is anything I should include in this answer to make sure that doesn't happen to someone else, let me know! – Vim Diesel Jul 13 '20 at 17:51
  • For me, only `brew cleanup` was needed as I already did a `brew upgrade` and this error was the result of that with node. – Jonathan Nov 16 '20 at 04:10
  • 1
    @AbandonedCart I voted negative because I thought this command dangerous for beginners. It's like estimulating Linux beginners to use rm -rf. Sorry, my opinion. – mpoletto Jan 08 '21 at 21:32
  • 1
    @mpoletto no worries! I try to give the appropriate warnings in the answer so anyone considering the solution would understand the impact. – Vim Diesel Jan 09 '21 at 00:12
  • @mpoletto I appreciate your concern for beginners, even if I am not sure why I was tagged. – Abandoned Cart Jan 09 '21 at 23:42
  • @AbandonedCart Sorry, but it doesn't appear or I can't see where I tagged you. – mpoletto Jan 12 '21 at 14:32
  • Worked wonderfully here. – Victor Mar 09 '21 at 04:08
  • This is a terrible response. Way too general. People who know what they're doing can get general solution out of specific solution, but people who don't know what they're doing can't get specific solution out of general solution like this. – J.Ko Apr 12 '21 at 18:28
  • @J.Ko you aren't completely wrong, but is not a good solution one that works? This error can occur due to a variety of brew issues and it seems to have helped get at least a few people unstuck. If you have a better solution I will happily upvote your answer. – Vim Diesel Apr 12 '21 at 20:10
  • 1
    @VimDiesel I don't have a solution. That's why I'm here looking for one. The one below this by Grey Black worked. – J.Ko Apr 13 '21 at 22:09
  • `brew upgrade` worked for me, I didn't need the cleanup – abumalick Apr 29 '21 at 09:22
  • `brew cleanup` worked for me but I also had to do a `brew update-reset` to fix brew afterward, as in [this answer to another question](https://stackoverflow.com/a/54913258/1399438). – StockB May 05 '21 at 17:11
313

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

Abandoned Cart
  • 3,230
  • 29
  • 32
Grey Black
  • 3,189
  • 1
  • 4
  • 4
  • 1
    This is exactly what happened to me as well, and you got me on the right track. The major caveat to this approach is that you have to have previously installed this version. I worked around this in my answer – Leland Jan 20 '19 at 03:04
  • 19
    I did not have 62.1 installed. `brew list icu4c` showed a files from `/usr/local/Cellar/icu4c/63.1`. `brew switch icu4c 63.1` fixed it for me. – Steven Ensslen Feb 28 '19 at 02:34
  • 4
    I found this page after finding this error in my Postgres logs. I also tried `brew switch icu4c 63.1` but still getting the same error in the logs, even after restarting postgres. Not sure what to do next... – Andrew Apr 09 '19 at 23:31
  • 30
    I ended up running `brew reinstall postgres` and that seemed to solve my problems – Andrew Apr 10 '19 at 07:46
  • 1
    Helps switch to `icu4c 61.1`. `63.1` - not solve. `62.1` - not found. – Pavel Petrovich Apr 13 '19 at 11:08
  • Thanks @grey-black it worked for me I am using following MacOS Mojave version 10.14.4 (18E226) – Sangam Pandey May 22 '19 at 06:30
  • 1
    @ApoorvParijat `62.1` is only what Grey Black had installed, not part of a literal command for every user on every system. – Abandoned Cart Jun 07 '19 at 19:53
  • Magic. Helped with 6.4 -> 6.3 – Azee Jun 11 '19 at 05:07
  • And I ended up with `brew reinstall php@7.2` – Rafał R Oct 02 '19 at 21:07
  • Explicitly switching to the already installed compatible version did the trick for me. postgres was looking for v64. v64 was indeed installed, it still cribbed with image not found error, but, started working when I explicitly set it to v64 – darkdefender27 Nov 18 '19 at 17:28
  • Worked for me but I think you mean "Where version is the version number in the 'Library not loaded' message." 62 in the OP's case. 64.2 in my case. – Rooster242 May 19 '20 at 20:02
  • 2
    Unfortunately brew switch no longer available. – zenon Apr 09 '21 at 04:42
118

I am actually quite surprised that this solution has not been presented yet, and I feel like it is the easiest solution.

Go to GitHub, find the version of the brewfile that matches the version of icu4c that you need and get the raw version of the file (follow the links above and click View File then Raw).

Then just have brew reinstall from that url.

For example, version 62.1:

brew reinstall https://raw.githubusercontent.com/Homebrew/homebrew-core/575eb4bbef683551e19f329f60456b13a558132f/Formula/icu4c.rb

For example, version 64.2:

brew reinstall https://raw.githubusercontent.com/Homebrew/homebrew-core/a806a621ed3722fb580a58000fb274a2f2d86a6d/Formula/icu4c.rb

UPDATE:

Later versions of Homebrew may require you to download the file first. If this is the case:

wget https://raw.githubusercontent.com/Homebrew/homebrew-core/a806a621ed3722fb580a58000fb274a2f2d86a6d/Formula/icu4c.rb
brew reinstall icu4c.rb
Kevin
  • 22,680
  • 2
  • 17
  • 21
Kevin Elliott
  • 2,370
  • 3
  • 21
  • 21
  • 2
    you are a life saver! – Brad Kent Oct 11 '19 at 01:56
  • 1
    This is actually the best solution if, ```brew switch icu4c 62.1``` doesn't work for you in the first instance. – saberprashant Jan 08 '20 at 13:08
  • 1
    This is the only thing that worked for me after hours of trying fixing npm. Thanks! – galfisher Jan 30 '20 at 22:33
  • 29
    Worked great! To fix error `dyld: Library not loaded: /usr/local/opt/icu4c/lib/libicui18n.64.dylib` this command fixed it: `brew reinstall https://raw.githubusercontent.com/Homebrew/homebrew-core/a806a621ed3722fb580a58000fb274a2f2d86a6d/Formula/icu4c.rb` – John Kary Apr 23 '20 at 20:35
  • This was exactly the solution i was looking for. I was having issues with a valet-php version still using an older version of icu4c whereas brew updated to a newer one. – Kozie Apr 24 '20 at 13:01
  • In my case, this are better than reinstall PHP, because I have Oracle OCI, that is a pain to reinstall. Thanks – RafaelQm May 13 '20 at 05:19
  • This is the best solution for me. I don't want do 'brew upgrade' everything which is not necessary at this moment. – januarvs May 17 '20 at 14:57
  • 2
    Unfortunately **brew upgrade** removes older linked version and for people who still wanna use new version and keep brew up to date: 1)Use mentioned command to install older version 2)Copy 64.2 dir from **/usr/local/Cellar/icu4c/** somewhere locally 3)Run `brew upgrade` to install latest version of icu4c 4)Copy saved dir in to the **/usr/local/Cellar/icu4c/** 5)Now you can switch between versions: `brew switch icu4c 64.2` – Ilia Rebane May 26 '20 at 17:59
  • 3
    For icu4c **66**: `brew reinstall https://raw.githubusercontent.com/Homebrew/homebrew-core/22fb699a417093cd1440857134c530f1e3794f7d/Formula/icu4c.rb` – Magnus W Jun 04 '20 at 21:18
  • 1
    For icu4c 67: brew reinstall https://raw.githubusercontent.com/Homebrew/homebrew-core/88b9cc789820f2f544d8d4a1053eebb044c2926c/Formula/icu4c.rb – Richard Frank Jun 09 '20 at 05:05
  • 8
    This doesn't work anymore. It asks you to `brew extract` – brunouno Sep 18 '20 at 01:53
  • 3
    @brunouno You need to download the .rb file and do: `brew reinstall icu4c.rb` – Patrick Fabrizius Nov 03 '20 at 15:23
  • 1
    version **67.1**: https://raw.githubusercontent.com/Homebrew/homebrew-core/8e4cfd6b1bc8b1f02b67d3bc5f98c7fe5ad2fb8c/Formula/icu4c.rb – Obed Marquez Parlapiano Mar 24 '21 at 14:22
  • It's generally recommended to go off specific versions, but adding this as another option (using master/latest). ```wget https://raw.githubusercontent.com/Homebrew/homebrew-core/master/Formula/icu4c.rb; brew reinstall icu4c.rb``` – Matt Kenefick May 13 '21 at 14:23
  • It did not worked for me, fixed by this new wonderful php tap: https://github.com/shivammathur/homebrew-php – palmic May 18 '21 at 11:41
78

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:

  1. We first need a deep clone of the Homebrew repo. This may take a while: git -C $(brew --repo homebrew/core) fetch --unshallow
  2. brew log icu4c to track down a commit that references 62.1; 575eb4b does the trick.
  3. cd $(brew --repo homebrew/core)
  4. git checkout 575eb4b -- Formula/icu4c.rb
  5. brew uninstall --ignore-dependencies icu4c
  6. brew install icu4c You should now have the correct version of the dependency! Now just to...
  7. git reset && git checkout . Cleanup your modified recipe.
  8. brew pin icu4c Pin the dependency to prevent it from being accidentally upgraded in the future

If you decide you do want to upgrade it at some point, make sure to run brew unpin icu4c

Leland
  • 1,427
  • 12
  • 17
  • When I do `brew log icu4c`, there's only 3-4 results. None mention 62.1. The hash you use above doesn't work either. Have they removed 62? – Noah Feb 07 '19 at 15:14
  • 2
    You should first do `git -C (brew --repo homebrew/core) fetch --unshallow` to make sure you have a full brew git history. – Noah Feb 07 '19 at 17:03
  • 51
    So much drama for a yarn upgrade. – Eric Walker Feb 10 '19 at 20:04
  • 4
    This is the only solution out there that worked for me, thank you! In my case the problem was ffmpeg package which, I assume, installed newer version of `icu4c`. Neither updating, upgrading brew worked, nor reinstalling, relinking, building php from source. – gedijedi Feb 19 '19 at 14:36
  • For me, I needed an even older version of icu4c. Applying these steps but searching for an older commit worked. To see which version you need, check the file in your error msg: `libicui18n.61.dylib` - in my case this meant I needed v.61. – TheKarateKid Mar 04 '19 at 22:43
  • Worked for me except I had to use `git -C "$(brew --repo homebrew/core)" fetch --unshallow` for step #1 – Jason Mar 11 '19 at 13:15
  • 5
    In my case I've needed icu4c v63, so the related commit to checkout is [bc0c97952453ff6afc146aa3a706e9902aba4300](https://github.com/Homebrew/homebrew-core/commit/bc0c97952453ff6afc146aa3a706e9902aba4300). The git command is `git checkout bc0c97952453ff6afc146aa3a706e9902aba4300 -- Formula/icu4c.rb` and then `brew switch 63.1` – nahuelhds Apr 23 '19 at 14:43
  • @gedijedi I recently installed ffmpeg and encountered the same error. Performing an update (`brew upgrade`) resolved the issue automatically and `brew switch` restored the php version I was using. No need to DIY a whole installation. – Abandoned Cart Jun 07 '19 at 20:03
  • I believe there's an easier way to do this (install a "previous" version of something via bew) ... this SO post worked simply and flawlessly for me: https://stackoverflow.com/a/55828190 – leo Jun 23 '19 at 09:14
  • Remeber to do ``` brew update``` before ```brew install icu4c```. As well, fetch the unshallow the command shown does not work, so what I did was cd $(brew --repo homebrew/core) then fetch --unshallow – Obromios Aug 24 '19 at 22:04
  • worked perfectly. It fixed it node, php, python and every other dependent package – Vinay Aggarwal Sep 08 '19 at 10:09
  • I don't know why but it installed the 64.1 version again instead of 62.1. I think ```brew update``` is required before installing it again. – saberprashant Jan 08 '20 at 13:04
  • this worked for me (like a charm!) thanks a lot! I was looking for version 64 (without a minor) I found (searching manually in GitHub) this commit: `896d1018c7a4906f2c3fa1386aaf283497db60a2` which references version "64.2" but it worked! php@5.6 is now working! – Khaleesi Jul 09 '20 at 20:56
  • 1
    This resulted in `==> Downloading https://ghcr.io/v2/homebrew/core/icu4c/manifests/67.1 #=#=-# # curl: (22) The requested URL returned error: 404 Error: Failed to download resource "icu4c_bottle_manifest" Download failed: https://ghcr.io/v2/homebrew/core/icu4c/manifests/67.1` when I tried to get version `67.1` with https://github.com/Homebrew/homebrew-core/commit/88b9cc789820f2f544d8d4a1053eebb044c2926c. – bluepanda May 04 '21 at 19:35
  • It did not worked for me, fixed by this new wonderful php tap: https://github.com/shivammathur/homebrew-php – palmic May 18 '21 at 11:41
64

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

Lucas Bustamante
  • 11,643
  • 6
  • 66
  • 74
44

I had the same problem after I upgraded my macOS to version 10.13.6. I can't run composer and php commands. After researching for a while and trying various solutions posted online, reinstalling php using homebrew 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.

Arun Karnati
  • 677
  • 5
  • 8
  • 10
    I got the same error running `node` after upgrading macOS to `10.14.2`, `brew reinstall node` was the ticket for me too – gnmerritt Dec 19 '18 at 03:36
  • I started getting this error after installing a new package with brew. Doing `brew upgrade` fixed it for me. – samurai jack Jan 08 '19 at 23:34
  • 1
    `brew reinstall php` may end up installing a different version to the current one. You may have to specify the version using `php@7.1` – Ryan Mar 14 '19 at 04:58
  • 4
    you can't get the current version by running `php -v` if your php is broken :p – gingerCodeNinja May 23 '19 at 17:55
  • 1
    @gingerCodeNinja that's true, perhaps this might help: for Mac OS, go to terminal and run `echo $PATH` (if you have `php`, you should see something like this: `/usr/local/opt/php@7.2/bin`) this is one way to find out what versions are currently being used. – Arun Karnati May 30 '19 at 20:39
31

This fixed it for me:

brew upgrade node
serdarsenay
  • 2,363
  • 19
  • 21
  • 1
    This worked for me as well. I never fully investigated it but I believe brew just fixed the dependencies as well while upgrading node. This felt a lot more contained in comparison to brew upgrade. – hendrikbeck Oct 14 '19 at 14:07
  • 1
    seems similar case, > 'brew reinstall node' did help me after switching to Catalina – greencrest Nov 21 '19 at 15:29
  • 1
    Oddly enough, this `/icu4c/lib/libicui18n.66.dylib` error suddenly occurred when I was running rspec. I stashed my handful of code changes, error still showed up. upgrading node fixed the problem! Thank you! – Jon Kern Jan 24 '21 at 05:19
  • 1
    Thanks :) I was about to try the other solutions - but this fixed my issue right away. – Nick Taras Mar 08 '21 at 23:04
  • This worked for me – Umang Mathur May 05 '21 at 22:53
10

Just brew remove php and brew install php did not work, nor did brew reinstall php. My solution was to do:

brew remove php
cd /usr/local/Cellar
rm -rf php/
brew install php
brew doctor
brew cleanup

Now php -v gives me:

PHP 7.3.2 (cli) (built: Feb 14 2019 10:08:45) ( NTS )
glajan
  • 101
  • 1
  • 2
10

Seems like it is impossible to link icu4c using brew after latest OS X update. Which makes things more interesting. The only solution I found working for me:

  1. Download and compile icu4c 62.1 to /usr/local/icu4c/62.1
mkdir ~/sources
cd ~/sources
wget http://download.icu-project.org/files/icu4c/62.1/icu4c-62_1-src.tgz
tar xvzf icu4c-62_1-src.tgz
cd icu/source/

sudo mkdir /usr/local/icu4c/62.1
./configure --prefix=/usr/local/icu4c/62.1
make
sudo make install
  1. Link libs:
ln -s /usr/local/icu4c/62.1/lib/*.dylib /usr/local/include/
  1. Set DYLD_LIBRARY_PATH in ~/.bash_profile:
export DYLD_LIBRARY_PATH=/usr/local/include
Dharman
  • 21,838
  • 18
  • 57
  • 107
  • 3
    I'm running PHP 7.1 and this was the only thing that worked for me. – WebTigers Apr 06 '20 at 19:37
  • In my case I needed the 64.2 version, so I downloaded it from https://github.com/unicode-org/icu/releases/download/release-64-2/icu4c-64_2-src.tgz – RafaelQm May 13 '20 at 05:56
  • 2
    After updating to OS Big Sur, icu4c 67 was missing, tried all kinds of solutions but this was the only one that worked. Downloaded it from https://github.com/unicode-org/icu/releases/download/release-67-1/icu4c-67_1-src.tgz . Thank you! – Sabine Jan 02 '21 at 16:35
  • 1
    This was moved to here: https://github.com/unicode-org/icu/releases/download/release-62-2/icu4c-62_2-src.tgz – Maros Apr 23 '21 at 23:06
6

I actually tried all of the solutions which made sense, mentioned in this post and yet i still got the same error when running php -v or composer. The node version was fine, npm as well there were no issues on having installed correct versions and they were all running. Running reinstall php@7.1 just threw an error. In the end i had to run:

brew reinstall icu4c

This basically worked, with me having to manually then install php dependencies such as imagick.so, imap.so As these libraries were installed for a project that i no longer maintain i can go without them. But if you do have dependancies on them, have in mind that there will be more work to do afterwards.

  • this worked for me! `npm install` wasn't working after my work macbook force updated to Catalina last week. Found here originally: https://gist.github.com/berkedel/d1fc6d13651c16002f64653096d1fded – Kingsley Apr 19 '21 at 13:21
3

In order to downgrade, i had to recompile from source (MacOS Mojave)

$ wget https://ssl.icu-project.org/files/icu4c/62.1/icu4c-62_1-src.tgz
$ tar xvfz icu4c-62_1-src.tgz
$ cd icu/sources
$ ./configure
$ make
$ make install
Taher
  • 10,838
  • 2
  • 27
  • 41
3

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.

Callum M
  • 678
  • 10
  • 19
3

brew update && brew upgrade worked for me

Simson
  • 2,905
  • 2
  • 18
  • 30
sanjok dangol
  • 61
  • 1
  • 5
3

This is what finally worked for me.

brew reinstall postgres

After running the above command you might need to run

brew postgresql-upgrade-database

to access your previous data.

Muzammil Baloch
  • 142
  • 1
  • 13
2

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.

Jerry
  • 2,852
  • 1
  • 17
  • 26
2

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.

Matt Rink
  • 327
  • 2
  • 12
2

On MacOS Mojave, only way I could fix it was with brew upgrade

2

i followed this article here and this seems to be the missing piece of the puzzle for me:

brew uninstall node@8
Nhan
  • 3,422
  • 6
  • 28
  • 35
gmansour
  • 631
  • 7
  • 7
2

my issue:

# npm install -g canvas

dyld: Library not loaded: /usr/local/opt/icu4c/lib/libicui18n.64.dylib
  Referenced from: /usr/local/opt/node@8/bin/node
  Reason: image not found

for now 20210118, after many try:

...
brew reinstall https://raw.githubusercontent.com/Homebrew/homebrew-core/master/Formula/icu4c.rb
brew upgrade npm
brew install node
brew uninstall --ignore-dependencies node@8 icu4c
brew install icu4c
...

Final worked solution is:

brew reinstall npm

crifan
  • 8,424
  • 1
  • 45
  • 35
2

2021-02 Easy solution

After years of dealing with this problem the following, surprisingly easy, solution worked for me:

  1. Open the raw file in your web browser of the version you need:

Version 62: https://raw.githubusercontent.com/Homebrew/homebrew-core/575eb4bbef683551e19f329f60456b13a558132f/Formula/icu4c.rb

Version 64: https://raw.githubusercontent.com/Homebrew/homebrew-core/a806a621ed3722fb580a58000fb274a2f2d86a6d/Formula/icu4c.rb

Version 66: https://raw.githubusercontent.com/Homebrew/homebrew-core/22fb699a417093cd1440857134c530f1e3794f7d/Formula/icu4c.rb

Version 67: https://raw.githubusercontent.com/Homebrew/homebrew-core/88b9cc789820f2f544d8d4a1053eebb044c2926c/Formula/icu4c.rb

Latest version: https://raw.githubusercontent.com/Homebrew/homebrew-core/master/Formula/icu4c.rb

  1. Copy paste the contents into a new file named: icu4c.rb
  2. Run the following on the newly created file: brew reinstall icu4c.rb

Source: https://gist.github.com/hgrimelid/703691ab48c4a4d0537cfe835b4d55a6

Laurence Cooper
  • 1,006
  • 1
  • 10
  • 20
  • I found a similar set of instructions, but it requires compiling the source: https://www.programmersought.com/article/34721476513/, which worked for me. – J.D. Pace Mar 11 '21 at 00:57
1

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

sgrwg
  • 11
  • 1
1

On OSX 10.15.4 running xcode-select --install fixed the issue for me.

Winter Faulk
  • 404
  • 5
  • 9
1

The solution in this gist did it for me

brew uninstall --ignore-dependencies node icu4c
brew install node
mokagio
  • 12,820
  • 2
  • 39
  • 49
1

In my case, brew update icu4c to version 67.1 so my php7.1 doesn't work. Just reinstall icu4c, then it fine.

Ref this: https://devhoi.com/threads/error-dyld-library-not-loaded-usr-local-opt-icu4c-lib-libicui18n-64-dylib-with-php7-1.26/

Huy Phan
  • 53
  • 2
  • i simply re-installed php 7.3 which is what was broken and it fixed it also. This guide pointed me in the right direction though. – Nate S Jul 08 '20 at 01:29
0

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.

0

I've tried many of the suggestions here, and at the end brew upgrade php is what did the trick for me, but seems the issue is all over the place

pcambra
  • 573
  • 6
  • 15
0

In my case I had to switch between two versions of icu4c since I still maintain PHP 5.6 projects (which use the old icu4c 64.2). brew install and reinstall from raw .rb links always replaces the previously installed versions for some reason.

#fetching 64.2
brew fetch https://raw.githubusercontent.com/Homebrew/homebrew-core/a806a621ed3722fb580a58000fb274a2f2d86a6d/Formula/icu4c.rb 

#fetching stable version
brew fetch https://raw.githubusercontent.com/Homebrew/homebrew-core/master/Formula/icu4c.rb 

cd $(brew --cache)/downloads
tar xvfz e2a83648f37dc5193016ce14fa6faeb97460258b214e805b1d7ce8956e83c1a7--icu4c-64.2.catalina.bottle.tar.gz
tar xvfz e045a709e2e21df31e66144a637f0c77dfc154f60183c89e6b04afa2fbda28ba--icu4c-67.1.catalina.bottle.tar.gz
mv -n icu4c/67.1 $(brew --cellar)/icu4c/
mv -n icu4c/64.2 $(brew --cellar)/icu4c/

then switch between versions

$ brew switch icu4c 64.2
Cleaning /usr/local/Cellar/icu4c/64.2
Cleaning /usr/local/Cellar/icu4c/67.1
Opt link created for /usr/local/Cellar/icu4c/64.2

$ brew switch icu4c 67.1
Cleaning /usr/local/Cellar/icu4c/64.2
Cleaning /usr/local/Cellar/icu4c/67.1
Opt link created for /usr/local/Cellar/icu4c/67.1
Taher
  • 10,838
  • 2
  • 27
  • 41
0

[2020] edition

For me, it was installing icu4c with the needed version.

If you need to install the old version like version 62, (same steps for else versions), you need to:

  1. Create your own repo (or find someones repo) with this version of brew tap (links are different for every version):

version 62

https://raw.githubusercontent.com/Homebrew/homebrew-core/575eb4bbef683551e19f329f60456b13a558132f/Formula/icu4c.rb

version 64

https://raw.githubusercontent.com/Homebrew/homebrew-core/a806a621ed3722fb580a58000fb274a2f2d86a6d/Formula/icu4c.rb 

version 66

https://raw.githubusercontent.com/Homebrew/homebrew-core/22fb699a417093cd1440857134c530f1e3794f7d/Formula/icu4c.rb

version 67

https://raw.githubusercontent.com/Homebrew/homebrew-core/88b9cc789820f2f544d8d4a1053eebb044c2926c/Formula/icu4c.rb
  1. [yourUsername]/homebrew-versions/Formula/
  2. Place downloaded file to 'Formula' folder
  3. brew tap [yourUsername]/homebrew-versions
  4. brew install [yourUsername]/homebrew-versions/icu4c
  5. You got it!

Where [yourUsername] is the name of your GitHub account or person who already have the needed version tap.

Unfortunately, latest homebrew gives no longer a warning and now displays the error: Error: Calling Installation of XXX from a GitHub commit URL is disabled! Use 'brew extract XXX' to stable tap on GitHub instead. So the way to go now is to create a new repo on github called homebrew-versions to host the Formula in a Tap Then initialise it with: brew tap-new MYORG/homebrew-versions after git cloning the homebrew repo as suggested by Shine Hugh, copy paste the raw ruby file to your new Formula. Beware the funny naming convention! Example: File name is: gettext@0.20.2.rb Class name is: GettextAT0202 Example: https://github.com/nedap/homebrew-versions

source:https://itnext.io/how-to-install-an-older-brew-package-add141e58d32

Valiyard
  • 58
  • 7
0

I just wanted to leave a detail summary on how to fix this issue at the current moment (this worked for me):

First go to the local installation of homebrew

cd /usr/local/Homebrew/

Homebrew > 2.5 remove the option to install formulas directly from git repos so we need to checkout an older version

git checkout 2.3.0

Install icu4c version (in my case 64.2 was compitable with php@7.1)

HOMEBREW_NO_AUTO_UPDATE=1 brew install https://raw.githubusercontent.com/Homebrew/homebrew-core/a806a621ed3722fb580a58000fb274a2f2d86a6d/Formula/icu4c.rb

Go back to current version of homebrew

git checkout -

Tell brew to use the old version of icu4c this way you can chose wich version to use if you have both intalled

brew switch icu4c 64.2
0

I solved int by updating all the R packages:

update.packages(checkBuilt = TRUE, ask = FALSE)
Dharman
  • 21,838
  • 18
  • 57
  • 107
Freeman
  • 5,246
  • 2
  • 41
  • 46
0

Actually, I found the solution directly on homebrew page: https://docs.brew.sh/Common-Issues

Upgrading macOS can cause errors like the following:

  • dyld: Library not loaded: /usr/local/opt/icu4c/lib/libicui18n.54.dylib configure: error: Cannot find libz
  • Following a macOS upgrade it may be necessary to reinstall the Xcode Command Line Tools and brew upgrade all installed formula:
xcode-select --install
brew upgrade

In my case the problem wasn't related to upgrading OS, but the solution worked nicely.

Ygnaaac
  • 9
  • 1
-2

in my case, I reinstall all packages installed with Homebrew

$ brew list | xargs brew reinstall

After that, I start to install my version that I need