MAC解决homebrew网络慢

MAC解决homebrew网络慢

tip:亲测有效

安装brew步骤(如果已经安装好,可跳过该步骤):

  • 1.任意位置打开终端,执行如下命令,下载brew安装的shell脚本

    • curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh >> brew_install.sh

    执行后生成一个brew_install.sh的shell脚本

  • 2.修改brew_install.sh脚本

    • vi brew_install.sh

    全局查找BREW_REPO = "https://github.com/Homebrew/brew"参数
    修改BREW_REPO的值为
    BREW_REPO = "https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/brew.git"

    • 3.增加可执行权限,执行该脚本进行安装

      • chmod 777 brew_install.sh
      • ./brew_install.sh
    • 4.如果到该步卡住了:

      ==> Tapping homebrew/core
          Cloning into ‘/usr/local/Homebrew/Library/Taps/homebrew/homebrew-core’…
      
      • 停止安装,进入如下文件夹:/usr/local/Homebrew/Library/

      • 删除Taps文件夹

      • 执行git clone git://mirrors.ustc.edu.cn/homebrew-core.git/ /usr/local/Homebrew/Library/Taps/homebrew/homebrew-core --depth=1

      • 5.安装成功:

    镜像换源

    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
```

接下来执行`brew update`会发现变快了很多
原文地址:https://www.cnblogs.com/jmtang/p/14210819.html