Skip to content

使用科大源安装 Homebrew / Linuxbrew

Homebrew 是一个包管理器,用来在 macOS 安装 Linux 工具包。链接:中科大开源镜像站

设置环境变量:

bash
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_BOTTLE_DOMAIN="https://mirrors.ustc.edu.cn/homebrew-bottles"
export HOMEBREW_API_DOMAIN="https://mirrors.ustc.edu.cn/homebrew-bottles/api"

安装脚本:

初次安装 Homebrew / Linuxbrew 时,如果无法下载安装脚本, 可以使用中科大源的每日同步的安装脚本文件。

bash
/bin/bash -c "$(curl -fsSL https://mirrors.ustc.edu.cn/misc/brew-install.sh)"

Homebrew Bottles

临时替换:

bash
export HOMEBREW_BOTTLE_DOMAIN="https://mirrors.ustc.edu.cn/homebrew-bottles"
export HOMEBREW_API_DOMAIN="https://mirrors.ustc.edu.cn/homebrew-bottles/api"

永久替换:

bash
# 对于 bash 用户
echo 'export HOMEBREW_BOTTLE_DOMAIN="https://mirrors.ustc.edu.cn/homebrew-bottles"' >> ~/.bash_profile
echo 'export HOMEBREW_API_DOMAIN="https://mirrors.ustc.edu.cn/homebrew-bottles/api"' >> ~/.bash_profile

# 对于 zsh 用户
echo 'export HOMEBREW_BOTTLE_DOMAIN="https://mirrors.ustc.edu.cn/homebrew-bottles"' >> ~/.zshrc
echo 'export HOMEBREW_API_DOMAIN="https://mirrors.ustc.edu.cn/homebrew-bottles/api"' >> ~/.zshrc

Homebrew Services

brew services 有关的文件,用于在 macOS (launchctl) 与 Linux (systemctl) 上管理 brew 安装的服务。

使用 USTC 镜像安装,或将已安装的仓库远程替换为 USTC 镜像:

bash
brew tap --custom-remote --force-auto-update homebrew/services https://mirrors.ustc.edu.cn/homebrew-services.git

重置为官方地址:

bash
brew tap --custom-remote --force-auto-update homebrew/services https://github.com/Homebrew/homebrew-services