与你分享
互联网的方方面面

macOS homebrew从国内镜像安装和更新方法

一、安装依赖

在命令行输入

xcode-select --install

安装CLT for Xcode。

二、从国内镜像下载脚本并安装

设置环境变量

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"

下载脚本并安装

curl -O https://cdn.jsdelivr.net/gh/Homebrew/install@master/install.sh
bash install.sh

三、配置从国内镜像更新

配置Homebrew源

cd "$(brew --repo)"
git remote set-url origin https://mirrors.ustc.edu.cn/brew.git

配置Homebrew Core源

cd "$(brew --repo)/Library/Taps/homebrew/homebrew-core"
git remote set-url origin https://mirrors.ustc.edu.cn/homebrew-core.git

配置Homebrew Cask源(可选)

cd "$(brew --repo)/Library/Taps/homebrew/homebrew-cask"
git remote set-url origin https://mirrors.ustc.edu.cn/homebrew-cask.git

配置Homebrew Services源(可选)

cd "$(brew --repo)/Library/Taps/homebrew/homebrew-services"
git remote set-url origin https://gitcode.net/mirrors/Homebrew/homebrew-services.git

配置Homebrew Bottles源

#Bash
echo 'export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.ustc.edu.cn/homebrew-bottles' >> ~/.bash_profile
source ~/.bash_profile

#zsh
echo 'export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.ustc.edu.cn/homebrew-bottles' >> ~/.zshrc
source ~/.zshrc

参考:

1、http://mirrors.ustc.edu.cn/help/brew.git.html

2、http://mirrors.ustc.edu.cn/help/homebrew-core.git.html

3、http://mirrors.ustc.edu.cn/help/homebrew-cask.git.html

4、http://mirrors.ustc.edu.cn/help/homebrew-bottles.html

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

6、https://gitcode.net/mirrors/Homebrew/homebrew-services

赞(1)
版权声明:本文采用知识共享 署名4.0国际许可协议 [BY-NC-SA] 进行授权
文章名称:《macOS homebrew从国内镜像安装和更新方法》
文章链接:https://wph.im/136.html
本站资源仅供个人学习交流,请于下载后24小时内删除,不允许用于商业用途,否则法律问题自行承担。

相关推荐

  • 暂无文章