Mac homebrew报错Error: homebrew-core is a shallow clone
Mac homebrew报错Error: homebrew-core is a shallow clone
1、现象
mac的brew出错,变化是操作系统升了个级。
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 command may take a few minutes to run due to the large size of the repository.
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!
2、解决方案
对于这个问题的解决,在报错中已经提示
git -C /usr/local/Homebrew/Library/Taps/homebrew/homebrew-core fetch --unshallow
但是,鉴于一定的因素,其同步速度特别慢,容易超时失败。可以考虑改用国内的镜像替代。
cd /usr/local/Homebrew/Library/Taps/homebrew/
rm -fr homebrew-core
cd /usr/local/Homebrew/Library/Taps/
mkdir homebrew
cd homebrew
git clone https://mirrors.tuna.tsinghua.edu.cn/git/homebrew-core.git
参考日志如下:
➜ homebrew git:(stable) git clone https://mirrors.tuna.tsinghua.edu.cn/git/homebrew-core.git
Cloning into 'homebrew-core'...
remote: Enumerating objects: 1205665, done.
remote: Counting objects: 100% (1205665/1205665), done.
remote: Compressing objects: 100% (390461/390461), done.
remote: Total 1205665 (delta 838256), reused 1170179 (delta 812067)
Receiving objects: 100% (1205665/1205665), 402.25 MiB | 977.00 KiB/s, done.
Resolving deltas: 100% (838256/838256), done.
Updating files: 100% (6435/6435), done.
➜ homebrew git:(stable) brew
Example usage:
brew search TEXT|/REGEX/
brew info [FORMULA|CASK...]
brew install FORMULA|CASK...
brew update
brew upgrade [FORMULA|CASK...]
brew uninstall FORMULA|CASK...
brew list [FORMULA|CASK...]
Troubleshooting:
brew config
brew doctor
brew install --verbose --debug FORMULA|CASK
Contributing:
brew create URL [--no-fetch]
brew edit [FORMULA|CASK...]
Further help:
brew commands
brew help [COMMAND]
man brew
https://docs.brew.sh
➜ homebrew git:(stable) brew update
Updated 1 tap (homebrew/core).
==> Outdated Formulae
freetds gettext libidn2 libtool libunistring ncurses openssl@1.1 pcre unixodbc wget zsh
You have 11 outdated formulae installed.
You can upgrade them with brew upgrade
or list them with brew outdated.
3、换源
网络上换源方法参考
## 更新 homebrew-cask
cd "$(brew --repo)"/Library/Taps/homebrew/homebrew-cask
# 更换源
git remote set-url origin https://mirrors.ustc.edu.cn/homebrew-cask.git
# 更新,由于已经 cd 到相应文件夹了,因此不需要通过 -C 指定路径了
git fetch --unshallow
## 更新 homebrew-core
cd "$(brew --repo)"/Library/Taps/homebrew/homebrew-core
# 更换源
git remote set-url origin https://mirrors.ustc.edu.cn/homebrew-core.git
# 更新
git fetch --unshallow
# 检查
git remote -v
如果出现问题,可以重设和强制更新
git fetch --all
git reset --hard origin/master
git pull