如何将macOS Homebrew更新为2026.3版本的国内镜像源?

摘要:✨Homebrew 镜像源说明 注:自 brew 4.0.0 (2023 年 2 月 16 日) 起,HOMEBREW_INSTALL_FROM_API 会成为默认行为,无需设置。大部分用户无需再克隆 homebrew-core 仓库,故无
✨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 ✨ 一键更换镜像源 清华源 使用如下命令可以单次写入多行字符 只需一条命令即可一键更换镜像源 注意:新的镜像源是追加而非覆盖到 ~/.bash_profile 或者 ~/.zprofile(防止误删其他配置) 如果之前在 ~/.bash_profile 或者 ~/.zprofile 中配置过其他镜像源请先删除 如需覆盖配置请将下列命令中的 >> 替换为 > bash cat << 'EOF' >> ~/.bash_profile eval "$(/opt/homebrew/bin/brew shellenv)" export HOMEBREW_BREW_GIT_REMOTE="https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/brew.git" export HOMEBREW_CORE_GIT_REMOTE="https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/homebrew-core.git" export HOMEBREW_API_DOMAIN="https://mirrors.tuna.tsinghua.edu.cn/homebrew-bottles/api" export HOMEBREW_BOTTLE_DOMAIN="https://mirrors.tuna.tsinghua.edu.cn/homebrew-bottles" EOF zsh cat << 'EOF' >> ~/.zprofile eval "$(/opt/homebrew/bin/brew shellenv)" export HOMEBREW_BREW_GIT_REMOTE="https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/brew.git" export HOMEBREW_CORE_GIT_REMOTE="https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/homebrew-core.git" export HOMEBREW_API_DOMAIN="https://mirrors.tuna.tsinghua.edu.cn/homebrew-bottles/api" export HOMEBREW_BOTTLE_DOMAIN="https://mirrors.tuna.tsinghua.edu.cn/homebrew-bottles" EOF 中科大源 bash cat << 'EOF' >> ~/.bash_profile eval "$(/opt/homebrew/bin/brew shellenv)" export HOMEBREW_BREW_GIT_REMOTE="https://mirrors.ustc.edu.cn/brew.git" export HOMEBREW_CORE_GIT_REMOTE="https://mirrors.ustc.edu.cn/homebrew-core.git" export HOMEBREW_API_DOMAIN="https://mirrors.ustc.edu.cn/homebrew-bottles/api" export HOMEBREW_BOTTLE_DOMAIN="https://mirrors.ustc.edu.cn/homebrew-bottles" EOF zsh cat << 'EOF' >> ~/.zprofile eval "$(/opt/homebrew/bin/brew shellenv)" export HOMEBREW_BREW_GIT_REMOTE="https://mirrors.ustc.edu.cn/brew.git" export HOMEBREW_CORE_GIT_REMOTE="https://mirrors.ustc.edu.cn/homebrew-core.git" export HOMEBREW_API_DOMAIN="https://mirrors.ustc.edu.cn/homebrew-bottles/api" export HOMEBREW_BOTTLE_DOMAIN="https://mirrors.ustc.edu.cn/homebrew-bottles" EOF 阿里源 bash cat << 'EOF' >> ~/.bash_profile eval "$(/opt/homebrew/bin/brew shellenv)" export HOMEBREW_BREW_GIT_REMOTE="https://mirrors.aliyun.com/homebrew/brew.git" export HOMEBREW_CORE_GIT_REMOTE="https://mirrors.aliyun.com/homebrew/homebrew-core.git" export HOMEBREW_API_DOMAIN="https://mirrors.aliyun.com/homebrew-bottles/api" export HOMEBREW_BOTTLE_DOMAIN="https://mirrors.aliyun.com/homebrew/homebrew-bottles" EOF zsh cat << 'EOF' >> ~/.zprofile eval "$(/opt/homebrew/bin/brew shellenv)" export HOMEBREW_BREW_GIT_REMOTE="https://mirrors.aliyun.com/homebrew/brew.git" export HOMEBREW_CORE_GIT_REMOTE="https://mirrors.aliyun.com/homebrew/homebrew-core.git" export HOMEBREW_API_DOMAIN="https://mirrors.aliyun.com/homebrew-bottles/api" export HOMEBREW_BOTTLE_DOMAIN="https://mirrors.aliyun.com/homebrew/homebrew-bottles" EOF ✨ 镜像源配置页 清华源 https://mirrors.tuna.tsinghua.edu.cn/help/homebrew/ 中科大源 https://mirrors.ustc.edu.cn/help/brew.git.html 阿里源 https://developer.aliyun.com/mirror/homebrew/ ⭐ 转载请注明出处 本文作者:双份浓缩馥芮白