Mac M2 Pro安装Homebrew遇服务器无响应,修改Hosts无效求助
解决Mac M2 Pro安装Homebrew时"Empty reply from server"报错的方法
1. 排查网络与代理问题
- 关闭所有代理工具(VPN、全局代理等),这类工具常导致GitHub请求被拦截或超时
- 切换手机热点/其他网络环境,排除本地运营商网络限制
2. 重置Git网络配置
- 执行命令清除Git的HTTP/HTTPS代理设置:
git config --global --unset http.proxy git config --global --unset https.proxy - 验证代理已清除:
git config --global --list
3. 使用国内镜像源安装
- 直接通过国内镜像的安装脚本执行安装:
/bin/bash -c "$(curl -fsSL https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/install.git)" - 安装完成后可配置国内镜像提升后续使用速度:
# 替换brew.git镜像地址 git -C "$(brew --repo)" remote set-url origin https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/brew.git # 替换homebrew-core.git镜像地址 git -C "$(brew --repo homebrew/core)" remote set-url origin https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/homebrew-core.git # 更新配置 brew update
4. 检查防火墙与安全软件
- 暂时关闭Mac自带防火墙(系统设置 > 网络 > 防火墙),确认是否是防火墙拦截请求
- 禁用第三方安全软件(如CleanMyMac、Little Snitch等)后重试安装
5. 手动克隆仓库完成安装
- 克隆Homebrew仓库到本地指定目录:
git clone https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/brew.git /usr/local/Homebrew - 创建软链接让brew命令全局可用:
ln -s /usr/local/Homebrew/bin/brew /usr/local/bin/brew - 初始化并更新Homebrew:
brew update
内容的提问来源于stack exchange,提问作者xin xiao
相关产品推荐
相关产品推荐

