Hi~ Darling!

MAC下Homebrew安装很慢的解决方案

获取install文件到本地,比如命名为brew_install:

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

打开brew_install文件进行修改:

1
BREW_REPO = "https://github.com/Homebrew/brew"

改为中国科大的源:

1
BREW_REPO = "https://mirrors.ustc.edu.cn/brew.git"

PS:网上大部分都是说要替换这两个↓ 但是我最新下载的install.sh文件并没有CORE_TAP_REPO并且也没有后缀.freeze 如果你也没有的话直接替换上面那一个就可以了,有的话理论上下载homebrew-core这两步你可以跳过了

1
2
3
4
5
BREW_REPO = “https://github.com/Homebrew/brew“.freeze 
CORE_TAP_REPO = “https://github.com/Homebrew/homebrew-core“.freeze
# 更改为这两句
BREW_REPO = "https://mirrors.ustc.edu.cn/brew.git".freeze
CORE_TAP_REPO = "https://mirrors.ustc.edu.cn/homebrew-core.git".freeze

保存以后ruby执行brew_install

1
ruby brew_install

此时脚本会停在 :

==> Tapping homebrew/core Cloning into ‘/usr/local/Homebrew/Library/Taps/homebrew/homebrew-core’…

Ctrl+C 停止就行了

下载homebrew-core

1
git clone git://mirrors.ustc.edu.cn/homebrew-core.git/ $(brew --repo homebrew/core) --depth=1

下载homebrew-cask

1
git clone git://mirrors.ustc.edu.cn/homebrew-cask.git/ $(brew --repo homebrew/cask) --depth=1

更换为中国科大镜像

1
2
3
git -C "$(brew --repo)" remote set-url origin https://mirrors.ustc.edu.cn/brew.git
git -C "$(brew --repo homebrew/core)" remote set-url origin https://mirrors.ustc.edu.cn/homebrew-core.git
git -C "$(brew --repo homebrew/cask)" remote set-url origin https://mirrors.ustc.edu.cn/homebrew-cask.git

安装成功、更新、检测

1
2
brew update
brew doctor

评论

Your browser is out-of-date!

Update your browser to view this website correctly. Update my browser now

×