使用国内源安装 Homebrew

转载来源

1、删除旧的安装

1
2
3
sudo rm -rf /usr/local/Homebrew
sudo rm -f /usr/local/bin/brew
sudo rm -rf /usr/local/var/homebrew

2、创建新的安装目录

sudo mkdir /usr/local/Homebrew

3、下载brew

sudo git clone https://mirrors.ustc.edu.cn/brew.git /usr/local/Homebrew

地址可更换为清华源https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/brew.git

如提示没有git,可通过xcode-select –install安装。

4、创建执行文件链接

sudo mkdir /usr/local/bin
sudo ln -s /usr/local/Homebrew/bin/brew /usr/local/bin/brew

5、创建brew-core目录

sudo mkdir -p /usr/local/Homebrew/Library/Taps/homebrew/homebrew-core

6、下载brew-core

sudo git clone https://mirrors.ustc.edu.cn/homebrew-core.git /usr/local/Homebrew/Library/Taps/homebrew/homebrew-core

地址可更换为清华源https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/homebrew-core.git

7、权限配置

1
2
3
sudo mkdir -p /usr/local/var/homebrew
sudo chown -R $(whoami) /usr/local/var/homebrew
sudo chown -R $(whoami) /usr/local/Homebrew

8、执行更新

brew update

提示Already up-to-date即为成功。如有问题可通过brew doctor自检命令检查一下。

9、设置环境变量

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

地址可更换为https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/homebrew-bottles

Licensed under CC BY-NC-SA 4.0
comments powered by Disqus
Built with Hugo
Theme Stack designed by Jimmy