安装Homebrew遇fetch-pack断开报错的解决求助
Homebrew安装失败:
fetch-pack: unexpected disconnect while reading sideband packet 解决方法 问题描述
执行Homebrew安装命令:
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
触发以下错误:
error: 1262 bytes of body are still expected MiB | 11.00 KiB/s fetch-pack: unexpected disconnect while reading sideband packet fatal: early EOF fatal: fetch-pack: invalid index-pack output Failed during: git fetch --force origin
已尝试git config --global http.postBuffer 157286400增大Git缓冲区,也开启了Git调试:
export GIT_TRACE_PACKET=1 export GIT_TRACE=1 export GIT_CURL_VERBOSE=1
问题仍未解决,且网络可正常浏览网页。
可行解决方案
切换Git传输协议为HTTPS
修改Homebrew仓库远程地址,替换SSH协议为HTTPS:git remote set-url origin https://github.com/Homebrew/brew.git若安装过程中触发问题,可直接通过HTTPS克隆仓库手动安装:
git clone https://github.com/Homebrew/brew.git cd brew ./install.sh禁用Git压缩
关闭Git的传输压缩功能,避免因压缩/解压缩断点导致失败:git config --global core.compression 0使用国内镜像源安装
替换为国内加速镜像执行安装命令:/bin/bash -c "$(curl -fsSL https://cdn.jsdelivr.net/gh/Homebrew/install@HEAD/install.sh)"安装完成后可配置镜像源避免后续更新问题:
git config --global url."https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/".insteadOf "https://github.com/Homebrew/"重置Git配置
若之前修改的Git配置引发冲突,重置为默认值:git config --global --unset http.postBuffer git config --global --unset core.compression
内容的提问来源于stack exchange,提问作者C.T.O
相关产品推荐
相关产品推荐

