You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Win11下用pacman安装mingw-w64 GCC失败及后续尝试问题

Windows 11下MSYS2安装mingw-w64-ucrt-x86_64-gcc失败的解决办法

问题现象

执行安装命令:

pacman -S mingw-w64-ucrt-x86_64-gcc

出现连接镜像服务器失败的错误,核心报错:

error: failed retrieving file 'xxx' from mirror.msys2.org : Failed to connect to mirror.msys2.org port 443 after 470 ms: Couldn't connect to server

尝试pacman-mirrors -f5时提示命令不存在,执行pacman -U /var/cache/pacman/pkg/ca-certificates*找不到对应包。

解决步骤

1. 手动更换国内镜像源

MSYS2没有pacman-mirrors命令(该命令属于Manjaro等发行版),需手动编辑镜像配置文件:

  • 打开MSYS2终端,编辑UCRT64环境的镜像列表:
nano /etc/pacman.d/mirrorlist.ucrt64
  • 将原有镜像地址注释掉(在行首加#),添加国内镜像地址,比如:
Server = https://mirrors.tuna.tsinghua.edu.cn/msys2/mingw/ucrt64/
Server = https://mirrors.ustc.edu.cn/msys2/mingw/ucrt64/
Server = https://mirrors.hit.edu.cn/msys2/mingw/ucrt64/
  • 保存退出后,更新本地数据库:
pacman -Sy
  • 重新执行安装命令。

2. 排查网络与代理问题

  • 关闭本地代理软件或VPN,避免网络拦截;
  • 若需代理访问,在MSYS2终端临时设置代理:
export http_proxy=http://127.0.0.1:1080
export https_proxy=http://127.0.0.1:1080

(替换为你的代理地址和端口)

  • 测试镜像服务器连通性:
curl https://mirrors.tuna.tsinghua.edu.cn/msys2/mingw/ucrt64/

能正常返回页面则网络正常。

3. 修复证书问题

若怀疑是SSL证书导致的连接失败,先更新并安装证书包:

pacman -Sy ca-certificates

安装完成后重新尝试安装GCC。

4. 清理缓存后重试

清理无效的缓存文件,重新下载:

pacman -Sc
pacman -S mingw-w64-ucrt-x86_64-gcc

内容的提问来源于stack exchange,提问作者BMamba24

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.05 18:45:06