brew 管理多版本php时, 遇到icu4c
版本过高导致php@56无法正常启动, 报错信息:
dyld: Library not loaded: /usr/local/opt/icu4c/lib/libicui18n.64.dylib
Referenced from: /usr/local/opt/php@5.6/sbin/php-fpm
Reason: image not found
在stackoverflow找到类似解决方法如下:
把下文中63版本改成这次报错的64版本即可解决
https://stackoverflow.com/questions/55826221/install-icu4c-version-63-with-homebrew
Solution:
1) cd to Homebrew's formula directory
cd $(brew --prefix)/Homebrew/Library/Taps/homebrew/homebrew-core/Formula
2) Find desired commit (version 63 for icu4c) to checkout
git log --follow icu4c.rb
3) Checkout to a new branch
git checkout -b icu4c-63 e7f0f10dc63b1dc1061d475f1a61d01b70ef2cb7
4) Reinstall the library with the new version
brew reinstall ./icu4c.rb
5) Switch to the reinstalled version
brew switch icu4c 63.1
6) Checkout back to master
git checkout master
Sources:
Homebrew install specific version of formula?
http://hanxue-it.blogspot.com/2018/08/macos-homebrew-installing-older-version-of-software.html
Bonus for those who ended up using this more than once:
# zsh
function hiicu63() {
local last_dir=$(pwd)
cd $(brew --prefix)/Homebrew/Library/Taps/homebrew/homebrew-core/Formula
git checkout icu4c-63
brew reinstall ./icu4c.rb
brew switch icu4c 63.1
git checkout master
cd $last_dir
}