mac修改国内源快速安装brew

我是参考了清华源官网,有任何困惑直接访问该网址即可。这里给出精简版。

1. 更改镜像到~/.zshrc

终端添加方式

echo export HOMEBREW_API_DOMAIN="https://mirrors.tuna.tsinghua.edu.cn/homebrew-bottles/api" >> ~/.zshrc

echo export HOMEBREW_BOTTLE_DOMAIN="https://mirrors.tuna.tsinghua.edu.cn/homebrew-bottles" >> ~/.zshrc

echo export HOMEBREW_BREW_GIT_REMOTE="https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/brew.git" >> ~/.zshrc

echo export HOMEBREW_CORE_GIT_REMOTE="https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/homebrew-core.git" >> ~/.zshrc

echo export HOMEBREW_PIP_INDEX_URL="https://pypi.tuna.tsinghua.edu.cn/simple" >> ~/.zshrc

或者直接在~/.zshrc添加以下内容

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"
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_PIP_INDEX_URL="https://pypi.tuna.tsinghua.edu.cn/simple"

接下来输入

source ~/.zshrc

2. 下载brew

依次输入以下命令

git clone --depth=1 https://mirrors.tuna.tsinghua.edu.cn git/homebrew/install.git brew-install

/bin/bash brew-install/install.sh

rm -rf brew-install

brew update

安装好了,查看源是否正确

brew config

3. 改问题

输入brew doctor

如果出现

Warning: Homebrew’s “sbin” was not found in your PATH but you have installed
formulae that put executables in /usr/local/sbin.
Consider setting your PATH for example like so:
echo ‘export PATH=“/usr/local/sbin:$PATH”’ >> ~/.zshrc

那就按照它说的输入

echo 'export PATH="/usr/local/sbin:$PATH"' >> ~/.zshrc

重新输入brew doctor

如果没问题,就会显示,大功告成

Your system is ready to brew.

你可能感兴趣的:(macos,brew,homebrew,清华源)