adb需要cask源,最新brew已标为可选,首选
1.清华源安装 + 替换仓上游
homebrew | 镜像站使用帮助 | 清华大学开源软件镜像站 | Tsinghua Open Source Mirror
设置环境变量:
export HOMEBREW_BREW_GIT_REMOTE="https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/brew.git"
export HOMEBREW_CORE_GIT_REMOTE="https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/homebrew-core.git"
export HOMEBREW_BOTTLE_DOMAIN="https://mirrors.tuna.tsinghua.edu.cn/homebrew-bottles"
安装 Homebrew:
# 从本镜像下载安装脚本并安装 Homebrew / Linuxbrew
git clone --depth=1 https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/install.git brew-install
/bin/bash brew-install/install.sh
rm -rf brew-install
Homebrew替换仓库上游:
export HOMEBREW_CORE_GIT_REMOTE="https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/homebrew-core.git"
for tap in core cask{,-fonts,-drivers,-versions} command-not-found; do
brew tap --custom-remote --force-auto-update "homebrew/${tap}" "https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/homebrew-${tap}.git"
done
brew update
最后brew install android-platform-tools 即可。
2. 若使用清华源安装失败,可换到中科大源安装
Homebrew 源使用帮助 — USTC Mirror Help 文档
设置环境变量并使用 jsDelivr CDN 下载 install.sh export HOMEBREW_BREW_GIT_REMOTE="https://mirrors.ustc.edu.cn/brew.git" export HOMEBREW_CORE_GIT_REMOTE="https://mirrors.ustc.edu.cn/homebrew-core.git" export HOMEBREW_BOTTLE_DOMAIN="https://mirrors.ustc.edu.cn/homebrew-bottles"
/bin/bash -c "$(curl -fsSL https://cdn.jsdelivr.net/gh/Homebrew/install@HEAD/install.sh)"
还不可brew install android-platform-tools,否则报错
==> Tapping homebrew/cask
Cloning into '/usr/local/Homebrew/Library/Taps/homebrew/homebrew-cask'...
fatal: unable to access 'https://github.com/Homebrew/homebrew-cask/': transfer closed with outstanding read data remaining
Error: Failure while executing; `git clone https://github.com/Homebrew/homebrew-cask /usr/local/Homebrew/Library/Taps/homebrew/homebrew-cask` exited with 128.
再替换清华源仓库上游安装(见上文步骤)
总结:常用国内Homebrew源有阿里云(aliyun),腾讯云(tencent),中科大(ustc), 清华(tsna), 22年初的使用状况来看,清华和中科大跟进外网brew较快,文档较为完整
但无论何种镜像,都要熟悉各个包管理工具,有条件的开发同学可选用更方便的梯子。