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

【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

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

相关

每秒可传输多少距离的光信号?细数光纤速度与数据传输率!
如何打印PDF文件?如何快速打印PDF文件?
365体育投注提款

如何打印PDF文件?如何快速打印PDF文件?

📅 07-01 👁️ 4787
win10平板模式如何找到回收站?win10平板模式找到回收站的方法