MacOS Homebrew下载替换国内镜像源

共需要替换几个部分的镜像源:homebrew、homebrew-core、homebrew-cask、homebrew-bottles。

1. 查看地址:

echo $(brew --repo)
echo $(brew --repo homebrew/core)
echo $(brew --repo homebrew/cask)

2. 修改homebrew、homebrew-core、homebrew-cask地址:

$ git -C "$(brew --repo)" remote set-url origin https://mirrors.aliyun.com/homebrew/brew.git
$ git -C "$(brew --repo homebrew/core)" remote set-url origin https://mirrors.aliyun.com/homebrew/homebrew-core.git
$ git -C "$(brew --repo homebrew/cask)" remote set-url origin https://mirrors.aliyun.com/homebrew/homebrew-cask.git

3. 修改homebrew-bottles地址:

先查看shell版本

echo $SHELL

如果输出是/bin/bash,执行:

$ echo 'export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.aliyun.com/homebrew/homebrew-bottles' >> ~/.bash_profile
$ source ~/.bash_profile

如果输出是/bin/zsh,执行:

$ echo 'export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.aliyun.com/homebrew/homebrew-bottles' >> ~/.zshrc
$ source ~/.zshrc

如果需要重置回地址为官方:

$ git -C "$(brew --repo)" remote set-url origin https://github.com/Homebrew/brew.git
$ git -C "$(brew --repo homebrew/core)" remote set-url origin https://github.com/Homebrew/homebrew-core
$ git -C "$(brew --repo homebrew/cask)" remote set-url origin https://github.com/Homebrew/homebrew-cask

4. 文档

阿里云镜像
Homebrew官网

posted @ 2024-05-08 11:10  Li_pk  阅读(334)  评论(0编辑  收藏  举报