0%

macbook | brew 修复

这次使用 brew 安装的时候,出现了一点 bug ,在这里记录相应的过程。


参考资料



造成的原因分析


有两个原因

  • brew 的版本需要更新
  • 我买了一个新电脑,用苹果自带的功能,把所有资料都 copy 过来「同型号电脑」,但是,新版的系统是 11 ,老版的是 10 ,所以,相当于升级了系统。

错误


我在 brew install 的时候,出现

Error:
  homebrew-core is a shallow clone.
To `brew update`, first run:
  git -C /usr/local/Homebrew/Library/Taps/homebrew/homebrew-core fetch --unshallow
This restriction has been made on GitHub's request because updating shallow 
clones is an extremely expensive operation due to the tree layout and traffic of
Homebrew/homebrew-core and Homebrew/homebrew-cask. We don't do this for you
automatically to avoid repeatedly performing an expensive unshallow operation in
CI systems (which should instead be fixed to not use shallow clones). Sorry for
the inconvenience!

直接说解决方案。

首先,判断是 homebrew-core 需要更新,但是,如果直接使用

git -C /usr/local/Homebrew/Library/Taps/homebrew/homebrew-core fetch --unshallow

会出现网速很慢,并且,下载下来后,安装错误「我出现了,下载下来安装错误。」所以,这样执行:

cd /usr/local/Homebrew/Library/Taps/homebrew
rm -rf homebrew-core
git clone https://mirrors.ustc.edu.cn/homebrew-core.git

这个是把清华园镜像的 homebrew-core 下载下来了。

但是,此时,继续执行 brew install 会出现

Error: python@3.9: wrong number of arguments (given 1, expected 0)

查了一下资料,说是需要安装

brew install cmake

但是,我安装这个,还是会出现

Error: python@3.9: wrong number of arguments (given 1, expected 0)

相当于走进了死胡同。这个时候,我看见上面还有一句

homebrew-cask is a shallow clone.

于是,模仿,homebrew-core ,我执行

cd /usr/local/Homebrew/Library/Taps/homebrew
rm -rf homebrew-cask
git clone https://mirrors.ustc.edu.cn/homebrew-cask.git

最后,问题解决。

在下面网站中,可以查到,镜像。

请我喝杯咖啡吧~