Mac brew update 慢~~~

正题开始之前, 如果对 Homebrew 不太了解, 这里有一篇很好的介绍文章: macOS 包管理工具 Homebrew 不完全指南 花个几分钟读一下, 绝对超值!

正题

Homebrew 通过 Git 来工作的, 默认的源是 Github. 因为众所周知的原因, update超级慢!

通过brew update -v可以查看update执行的详细信息, 找到究竟是哪一步比较慢(管他哪一步慢, 往下看

解决办法无外乎两种: 1. 切换成国内源 2. 走 Proxy

这里采用第一种方法, 步骤如下:

  1. 替换 brew.git:
    # 切换到 Homebrew 目录
    cd "$(brew --repo)"
    # 切换成阿里源, 其实就是改了远程仓库的地址
    git remote set-url origin https://mirrors.aliyun.com/homebrew/brew.git
    
  2. 替换 homebrew-core.git:
    cd "$(brew --repo)/Library/Taps/homebrew/homebrew-core"
    git remote set-url origin https://mirrors.aliyun.com/homebrew/homebrew-core.git
    
  3. 替换 homebrew-bottles: 二进制文件, **注意自己机器上使用的 SHELL **
    echo 'export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.aliyun.com/homebrew/homebrew-bottles' >> ~/.zshrc
    source ~/.zshrc
    
  4. 替换 homebrew-cask.git: cask 表示 GUI 应用的源, 阿里云没有提供 cask 源, 故使用 USTC 源
    cd "$(brew --repo)"/Library/Taps/homebrew/homebrew-cask
    git remote set-url origin https://mirrors.ustc.edu.cn/homebrew-cask.git
    

切换成国内源之后, update 起来如丝般顺滑 😃

brew update -v

如果不爽可以随时改回去, 以下是官方源:

  1. https://github.com/Homebrew/brew.git
  2. https://github.com/Homebrew/homebrew-core.git
  3. https://github.com/Homebrew/homebrew-cask

完~~~

posted @ 2019-10-13 00:54  关小曦  阅读(3002)  评论(0编辑  收藏  举报