Homebrew镜像源加速

执行 brew 命令安装软件的时候,跟以下 3 个仓库地址有关

  • brew.git

  • homebrew-core.git

  • homebrew-bottles

Alibaba镜像源

  • 替换brew仓库

    cd "$(brew --repo)"
    git remote set-url origin https://mirrors.aliyun.com/homebrew/brew.git
    
  • 替换homebrew-core仓库

    cd "$(brew --repo)/Library/Taps/homebrew/homebrew-core"
    git remote set-url origin https://mirrors.aliyun.com/homebrew/homebrew-core.git
    
  • 替换homebrew-bottles仓库,这个步骤跟MacOS 系统使用的 shell 版本有关系

    先查看当前使用的 shell 版本

    echo $SHELL
    

    如果输出结果是 /bin/zsh,参考zsh 终端操作方式 如果输出结果是 /bin/bash,参考bash 终端操作方式

    zsh 终端操作方式

    替换homebrew-bottles 访问地址:

    echo 'export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.aliyun.com/homebrew/homebrew-bottles' >> ~/.zshrc
    source ~/.zshrc
    

    bash 终端操作方式

    替换 homebrew-bottles 访问地址:

    echo 'export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.aliyun.com/homebrew/homebrew-bottles' >> ~/.bash_profile
    source ~/.bash_profile
    

See also