当前位置: 首页 > news >正文

【macOS】Homebrew更换国内镜像源(2025.7更新)

✨Homebrew 镜像源说明

注:自 brew 4.0.0 (2023 年 2 月 16 日) 起,HOMEBREW_INSTALL_FROM_API 会成为默认行为,无需设置。大部分用户无需再克隆 homebrew-core 仓库,故无需设置 HOMEBREW_CORE_GIT_REMOTE 环境变量;但若需要运行 brew 的开发命令或者 brew 安装在非官方支持的默认 prefix 位置,则仍需设置 HOMEBREW_CORE_GIT_REMOTE 环境变量。如果不想通过 API 安装,可以设置 HOMEBREW_NO_INSTALL_FROM_API=1

注:目前,homebrew-cask-{drivers,versions,fonts} 已被弃用,所有 cask 合并至 homebrew-cask 仓库。本帮助内已移除克隆这些仓库的命令。已克隆用户(brew tap 查看)可使用 brew untap 移除废弃的仓库。

以上内容来自 homebrew 清华镜像源


✨Homebrew 更换国内镜像源

此前通过更换 git remote url 方式更换镜像源

https://www.cnblogs.com/Flat-White/p/15706030.html


认真阅读了镜像源配置页

正确的方式应该是配置相关环境变量

具体配置方式如下


更换清华源

bash

echo 'eval "$(/opt/homebrew/bin/brew shellenv)"' >> ~/.bash_profile
echo 'export HOMEBREW_BREW_GIT_REMOTE="https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/brew.git"' >> ~/.bash_profile
echo 'export HOMEBREW_CORE_GIT_REMOTE="https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/homebrew-core.git"' >> ~/.bash_profile
echo 'export HOMEBREW_API_DOMAIN="https://mirrors.tuna.tsinghua.edu.cn/homebrew-bottles/api"' >> ~/.bash_profile
echo 'export HOMEBREW_BOTTLE_DOMAIN="https://mirrors.tuna.tsinghua.edu.cn/homebrew-bottles"' >> ~/.bash_profile

zsh

echo 'eval "$(/opt/homebrew/bin/brew shellenv)"' >> ~/.zprofile
echo 'export HOMEBREW_BREW_GIT_REMOTE="https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/brew.git"' >> ~/.zprofile
echo 'export HOMEBREW_CORE_GIT_REMOTE="https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/homebrew-core.git"' >> ~/.zprofile
echo 'export HOMEBREW_API_DOMAIN="https://mirrors.tuna.tsinghua.edu.cn/homebrew-bottles/api"' >> ~/.zprofile
echo 'export HOMEBREW_BOTTLE_DOMAIN="https://mirrors.tuna.tsinghua.edu.cn/homebrew-bottles"' >> ~/.zprofile

更换中科大源

bash

echo 'eval "$(/opt/homebrew/bin/brew shellenv)"' >> ~/.bash_profile
echo 'export HOMEBREW_BREW_GIT_REMOTE="https://mirrors.ustc.edu.cn/brew.git"' >> ~/.bash_profile
echo 'export HOMEBREW_CORE_GIT_REMOTE="https://mirrors.ustc.edu.cn/homebrew-core.git"' >> ~/.bash_profile
echo 'export HOMEBREW_API_DOMAIN="https://mirrors.ustc.edu.cn/homebrew-bottles/api"' >> ~/.bash_profile
echo 'export HOMEBREW_BOTTLE_DOMAIN="https://mirrors.ustc.edu.cn/homebrew-bottles"' >> ~/.bash_profile

zsh

echo 'eval "$(/opt/homebrew/bin/brew shellenv)"' >> ~/.zprofile
echo 'export HOMEBREW_BREW_GIT_REMOTE="https://mirrors.ustc.edu.cn/brew.git"' >> ~/.zprofile
echo 'export HOMEBREW_CORE_GIT_REMOTE="https://mirrors.ustc.edu.cn/homebrew-core.git"' >> ~/.zprofile
echo 'export HOMEBREW_API_DOMAIN="https://mirrors.ustc.edu.cn/homebrew-bottles/api"' >> ~/.zprofile
echo 'export HOMEBREW_BOTTLE_DOMAIN="https://mirrors.ustc.edu.cn/homebrew-bottles"' >> ~/.zprofile

更换阿里源

bash

echo 'eval "$(/opt/homebrew/bin/brew shellenv)"' >> ~/.bash_profile
echo 'export HOMEBREW_BREW_GIT_REMOTE="https://mirrors.aliyun.com/homebrew/brew.git"' >> ~/.bash_profile
echo 'export HOMEBREW_CORE_GIT_REMOTE="https://mirrors.aliyun.com/homebrew/homebrew-core.git"' >> ~/.bash_profile
echo 'export HOMEBREW_API_DOMAIN="https://mirrors.aliyun.com/homebrew-bottles/api"' >> ~/.bash_profile
echo 'export HOMEBREW_BOTTLE_DOMAIN="https://mirrors.aliyun.com/homebrew/homebrew-bottles"' >> ~/.bash_profile

zsh

echo 'eval "$(/opt/homebrew/bin/brew shellenv)"' >> ~/.zprofile
echo 'export HOMEBREW_BREW_GIT_REMOTE="https://mirrors.aliyun.com/homebrew/brew.git"' >> ~/.zprofile
echo 'export HOMEBREW_CORE_GIT_REMOTE="https://mirrors.aliyun.com/homebrew/homebrew-core.git"' >> ~/.zprofile
echo 'export HOMEBREW_API_DOMAIN="https://mirrors.aliyun.com/homebrew-bottles/api"' >> ~/.zprofile
echo 'export HOMEBREW_BOTTLE_DOMAIN="https://mirrors.aliyun.com/homebrew/homebrew-bottles"' >> ~/.zprofile

✨ 镜像源配置页

清华源

https://mirrors.tuna.tsinghua.edu.cn/help/homebrew/

中科大源

https://mirrors.ustc.edu.cn/help/brew.git.html

阿里源

https://developer.aliyun.com/mirror/homebrew/


⭐ 转载请注明出处

本文作者:双份浓缩馥芮白

原文链接:https://www.cnblogs.com/Flat-White/p/19008881

版权所有,如需转载请注明出处。

http://www.vanclimg.com/news/215.html

相关文章:

  • 第二十三天
  • SqlSugar的无实体(匿名)插入、更新、删除、查询以及多库和跨库查询 - microsoft
  • Cursor:IT专业人员必备神器,从开发到运维的全能助手.250423
  • 工作要开心:与其挣扎,不如选择自洽.250411
  • CSP-S模拟赛28 比赛总结
  • 校招季人效提升50%:Moka校招系统AI筛选与雇主品牌工具
  • 【2025-07-26】连岳摘抄
  • 迎战DARPA网络挑战赛:Trail of Bits的自动化安全系统征程
  • 企业如何利用MyEMS开源能源管理系统实现节能减排
  • GPUStack v0.7重磅发布:macOS与Windows安装包、昇腾MindIE多机推理、模型使用计量与寒武纪MLU支持
  • IDEA导出数据库对应的实体配置
  • 2025最佳代码托管平台推荐
  • 搜索
  • 服务器docker
  • 一种绕定轴旋转的参照系上的惯性力推导方法
  • 划分点(Vertex)和边(Edge)的属性汇总
  • 基本算法
  • JimuReport 积木报表 v2.1.1 版本发布,免费开源的报表和大屏设计
  • 一期6.文本摘要(md版)
  • 虚拟机之间实现免密登录,SSH密钥认证
  • 新认识了一个既简单又好用的AI修图工具丨PhotoDirector Ultra 2025 v16.6 相片大师
  • LGP4171 [JSTS 2010] 满汉全席 学习笔记
  • 2025年7款效率翻倍项目管理软件工具清单,项目经理生存手册!
  • Java初步了解
  • 微服务学习-01-微服务技术栈导学
  • CVE-2021-25646 Apache Druid 远程代码执行漏洞 (复现)
  • 9N90-ASEMI工业驱动专用9N90
  • 读后感
  • 我的 10 级 Claude Code 速查表让你几分钟内变专家(你现在是第几级?)
  • Docker容器服务端口探测 - Leonardo