Mac ox Homebrew 安装配置

卸载原有环境

  /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/uninstall)"

安装

官方安装命令

直接执行命令

/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

如果上述安装方式出现time out 等问题,执行下面安装方式

手动安装

下载安装配置文件

  1. 执行下载命令
curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install >> brew_install
  1. 编辑文件
vi brew_install
  1. 替换内容
    将BREW_REPO和CORE_TAP_REPO替换为下面内容(两个参数不存在就新建)
BREW_REPO = "https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/brew.git".freeze
CORE_TAP_REPO = "https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/homebrew-core.git".freeze
  1. 安装homebrew
    运行安装配置脚本
/usr/bin/ruby ./brew_install
  1. 如果出现下列报错
==> Tapping homebrew/core

Cloning into '/usr/local/Homebrew/Library/Taps/homebrew/homebrew-core'...

fatal: unable to access 'https://github.com/Homebrew/homebrew-core/': LibreSSL SSL_read: SSL_ERROR_SYSCALL, errno 54

Error: Failure while executing: git clone https://github.com/Homebrew/homebrew-core /usr/local/Homebrew/Library/Taps/homebrew/homebrew-core --depth=1

Error: Failure while executing: /usr/local/bin/brew tap homebrew/core

liyuanbadeMacBook-Pro:~ liyuanba$ git clone https://github.com/Homebrew/homebrew-core /usr/local/Homebrew/Library/Taps/homebrew/homebrew-core --depth=1

以上错误需要执行手动下载

git clone git://mirrors.ustc.edu.cn/homebrew-core.git/ /usr/local/Homebrew/Library/Taps/homebrew/homebrew-core --depth=1
  1. 修改home-core为国内源
cd "$(brew --repo)"

git remote set-url origin https://mirrors.ustc.edu.cn/brew.git

cd "$(brew --repo)/Library/Taps/homebrew/homebrew-core"

git remote set-url origin https://mirrors.ustc.edu.cn/homebrew-core.git
  1. 更新
brew update
  1. 检查
brew doctor
  1. 替换核心软件仓库为国内 USTC 源
cd "$(brew --repo)/Library/Taps/homebrew/homebrew-core"
git remote set-url origin https://mirrors.ustc.edu.cn/homebrew-core.git
  1. 替换 cask 软件仓库(提供 macOS 应用和大型二进制文件)
cd "$(brew --repo)"/Library/Taps/caskroom/homebrew-cask
git remote set-url origin https://mirrors.ustc.edu.cn/homebrew-cask.git
  1. 替换 Bottles 源(Homebrew 预编译二进制软件包)

bash(默认 shell)用户:

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

References

HomeBrew 官方安装太慢而失败?这么搞就行.(转载)
Homebrew卸载、安装与更改清华镜像

你可能感兴趣的:(Mac ox Homebrew 安装配置)