Mac Homebrew 国内镜像源替换或重置
c507e0a3c99a470da92c5366ef2bcb8e
Homebrew 安装
Homebrew是一款包管理工具,目前支持macOS和linux系统。安装方式很简单,将下面👇命令复制到命令行终端运行即可。
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
查看当前Homebrew 镜像源
# brew.git镜像源
git -C "$(brew --repo)" remote -v
# homebrew-core.git镜像源
git -C "$(brew --repo homebrew/core)" remote -v
# homebrew-cask.git镜像源
git -C "$(brew --repo homebrew/cask)" remote -v
Homebrew 换源(科大):
git -C "$(brew --repo)" remote set-url origin https://mirrors.ustc.edu.cn/brew.git
git -C "$(brew --repo homebrew/core)" remote set-url origin https://mirrors.ustc.edu.cn/homebrew-core.git
git -C "$(brew --repo homebrew/cask)" remote set-url origin https://mirrors.ustc.edu.cn/homebrew-cask.git
if [ $SHELL = "/bin/bash" ] # 如果你的是bash
then
echo 'export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.ustc.edu.cn/homebrew-bottles/' >> ~/.bash_profile
source ~/.bash_profile
elif [ $SHELL = "/bin/zsh" ] # 如果用的shell 是zsh 的话
then
echo 'export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.ustc.edu.cn/homebrew-bottles/' >> ~/.zshrc
source ~/.zshrc
fi
brew update
恢复原有镜像源(国内镜像源突然不能用了或版本不够新)
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
git -C "$(brew --repo homebrew/cask)" remote set-url origin https://github.com/Homebrew/homebrew-cask.git
# 找到 ~/.bash_profile 或者 ~/.zshrc 中的HOMEBREW_BOTTLE_DOMAIN 一行删除
brew update
Homebrew 重置
brew doctor
brew update-reset
brew update
参考链接
- Homebrew 安装
- 查看当前Homebrew 镜像源
- Homebrew 换源(科大):
- 恢复原有镜像源(国内镜像源突然不能用了或版本不够新)
- Homebrew 重置
- 参考链接