3

前情提要

我的当前版本Homebrew 3.1.7,系统环境11.3.1
也是手残,brew upgrade把所有的包都给更新以后,接着一把梭敲了brew cleanup
发现php依赖的icu4c版本对不上了。

$php -v
dyld: Library not loaded: /opt/homebrew/opt/icu4c/lib/libicui18n.68.dylib
  Referenced from: /opt/homebrew/opt/php@7.1/bin/php
  Reason: image not found
[1]    54859 abort      php -v

brew switch 失效

$brew switch icu4c 68
Error: Unknown command: switch

参考:https://github.com/Homebrew/d...

raw文件安装 失效

打开brew github地址
找到需要安装的68版本raw

$brew install https://raw.githubusercontent.com/Homebrew/homebrew-core/284ffd99cb862671202e685d7eced806bbc30dc4/Formula/icu4c.rb
Traceback (most recent call last):
    1: from /opt/homebrew/Library/Homebrew/formulary.rb:185:in `klass'
/opt/homebrew/Library/Homebrew/formulary.rb:277:in `load_file': Invalid usage: Installation of icu4c from a GitHub commit URL is unsupported! `brew extract icu4c` to a stable tap on GitHub instead. (UsageError)

强制安装

$cd $(brew --prefix)/Homebrew/Library/Taps/homebrew/homebrew-core/Formula
$rm icu4c.rb 
$vim icu4c.rb 
//输入 raw 68.2版本内的内容 保存退出
$brew reinstall icu4c
…………………………

$php -v
PHP 7.1.33 (cli) (built: Feb 28 2021 06:44:57) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.1.0, Copyright (c) 1998-2018 Zend Technologies
    with Xdebug v2.9.8, Copyright (c) 2002-2020, by Derick Rethans
    with Zend OPcache v7.1.33, Copyright (c) 1999-2018, by Zend Technologies

锁定版本 以免出错

$brew pin icu4c

回滚强制修改的brew文件

$cd /opt/homebrew/Library/Taps/homebrew/homebrew-core && git stash && git clean -d -f
$brew outdated
icu4c (68.2) < 69.1 [pinned at 68.2]

buildyuan
95 声望6 粉丝

talk is cheap,show me the code