mac 安装 homebrew

269 阅读1分钟

如何安装

通过 homebrew 官网(brew.sh/) 的方式安装,大概率会遇到下面的问题

Failed to connect to raw.githubusercontent.com port 443: Connection refused

通过修改 /etc/hosts 来指定 raw.githubusercontent.com ip地址的方式,跑到一半还是有问题。 于是尝试了下面的方法

改用通过brew镜像的方式安装亲测有效

/usr/bin/ruby -e "$(curl -fsSL https://cdn.jsdelivr.net/gh/ineo6/homebrew-install/install)"

homebrew主要是用来安装软件的,但是一般情况下它比较慢,所以需要更改它的安装源以提高安装速度

  • 替换brew.git
git -C "$(brew --repo)" remote set-url origin https://mirrors.ustc.edu.cn/brew.git
  • 替换homebrew-core.git
git -C "$(brew --repo homebrew/core)" remote set-url origin https://mirrors.ustc.edu.cn/homebrew-core.git

下面两个可以按需设置

  • 替换homebrew-cast.git
git -C "$(brew --repo homebrew/cask)" remote set-url origin https://mirrors.ustc.edu.cn/homebrew-cask.git
  • 替换homebrew-bottles 如果mac的终端工具用的是 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

通过brew安装软件遇到 ‘No formulae or casks found for **’ 的问题

我通过以下方式解决此问题

brew update-reset

参考文章

Mac安装Homebrew的正确姿势

参考链接

stackoverflow.com/questions/7…