安装Homebrew时遇“Failed to query latest Homebrew/brew Git tag”错误求助
解决Homebrew安装时“Failed to query latest Homebrew/brew Git tag”错误的方案
以下是几个经过验证的解决方法,按优先级尝试:
手动指定Git标签版本安装
自动查询标签失败时,可直接指定最新的稳定Git标签执行安装脚本。比如替换成当前最新的稳定版本号(如4.2.20):/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" -- --git-tag=4.2.20注:版本号可根据Homebrew官方仓库的最新稳定标签自行替换。
检查并修复Git网络访问
先测试Git能否正常访问Homebrew仓库:git clone https://github.com/Homebrew/brew.git如果克隆失败,说明网络存在访问限制:
- 若使用代理,确认代理配置正确,可重新设置Git代理:
git config --global http.proxy http://your-proxy-address:port git config --global https.proxy http://your-proxy-address:port - 若未使用代理,尝试切换网络(如手机热点)或关闭防火墙/安全软件后重试。
- 若使用代理,确认代理配置正确,可重新设置Git代理:
清理残留文件并重置Git配置
若之前安装失败留下残留文件,可能导致后续查询异常:rm -rf /usr/local/Homebrew rm -rf ~/.brew同时重置Git的远程仓库替换配置,避免地址解析错误:
git config --global --unset url."https://github.com/".insteadOf git config --global --unset url."git@github.com:".insteadOf使用国内镜像源安装
国内访问GitHub不稳定时,切换至国内镜像源的安装脚本:/bin/bash -c "$(curl -fsSL https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/install.git)"
内容的提问来源于stack exchange,提问作者Pratik Poudel
相关产品推荐
相关产品推荐

