OSX|更换brew源解决下载慢问题


在Mac下,brew install xxx的时候,经常卡在Updating Homebrew...这步很长时间.
这是因为brew每次执行的时候,都会去github检查有没有更新造成很慢.

通过brew udpate -v命令可以观察到,影响brew速度的主要是三个git地址+一个下载:


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

HOMEBREW_BOTTLE_DOMAIN

查看配置

$ brew config
HOMEBREW_VERSION: 2.2.11-110-g0859115
ORIGIN: https://github.com/Homebrew/brew.git
HEAD: 0859115a2400b4548a52a8b67656601c46c64db5
Last commit: 17 hours ago
Core tap ORIGIN: https://github.com/Homebrew/homebrew-core.git
Core tap HEAD: e0f4187b4e9aebf91624730aadc121a5510fa450
Core tap last commit: 3 hours ago
HOMEBREW_PREFIX: /usr/local
HOMEBREW_DEV_CMD_RUN: 1
CPU: octa-core 64-bit kabylake
Homebrew Ruby: 2.6.3 => /usr/local/Homebrew/Library/Homebrew/vendor/portable-ruby/2.6.3/bin/ruby
Clang: 11.0 build 1103
Git: 2.24.1 => /Applications/Xcode.app/Contents/Developer/usr/bin/git
Curl: 7.64.1 => /usr/bin/curl
Java: 1.8.0_60
macOS: 10.15.3-x86_64
CLT: 11.0.33.17
Xcode: 11.4

换成淘宝源

git -C "$(brew --repo)" remote set-url origin https://mirrors.aliyun.com/homebrew/brew.git
git -C "$(brew --repo homebrew/core)" remote set-url origin  https://mirrors.aliyun.com/homebrew/homebrew-core.git

export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.aliyun.com/homebrew/homebrew-bottles

换成官方

git -C "$(brew --repo)" remote set-url origin https://github.com/Homebrew/brew.git
git -C "$(brew --repo homebrew/core)" remote set-url origin https://github.com/Homebrew/homebrew-core.git
git -C "$(brew --repo homebrew/cask)" remote set-url origin https://github.com/Homebrew/homebrew-cask.git

换成中科大

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-cask.git
git -C "$(brew --repo homebrew/cask)" remote set-url origin https://mirrors.ustc.edu.cn/homebrew-core.git

HOMEBREW_BOTTLE_DOMAIN=https://mirrors.ustc.edu.cn/homebrew-bottles

换成清华源

git -C "$(brew --repo)" remote set-url origin https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/brew.git
git -C "$(brew --repo homebrew/core)" remote set-url origin https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/homebrew-core.git
git -C "$(brew --repo homebrew/cask)" remote set-url origin https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/homebrew-cask.git

export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.tuna.tsinghua.edu.cn/homebrew-bottles

参考: https://mirrors.tuna.tsinghua.edu.cn/help/homebrew/

  • 问题处理

    • rm -fr ".git/rebase-apply"
    fatal: It seems that there is already a rebase-apply directory, and
    I wonder if you are in the middle of another rebase.  If that is the
    case, please try
    git rebase (--continue | --abort | --skip)
    If that is not the case, please
    rm -fr ".git/rebase-apply"
    and run me again.  I am stopping in case you still have something
    valuable there.
    Error: homebrew/cask/tcl-tk 8.6.9_1 is already installed
    To upgrade to 8.6.10, run brew upgrade homebrew/cask/tcl-tk

    解决

    $ cd $(brew --repo)
    $ brew -v install tcl-tk
    Updating Homebrew...
    ==> Auto-updated Homebrew!
    Updated Homebrew from e94fff894 to 0859115a2.
    No changes to formulae.
    Error: homebrew/cask/tcl-tk 8.6.9_1 is already installed
    To upgrade to 8.6.10, run brew upgrade homebrew/cask/tcl-tkbrew -v install tcl-tk
    Updating Homebrew...
    ==> Auto-updated Homebrew!
    Updated Homebrew from e94fff894 to 0859115a2.
    No changes to formulae.
    Error: homebrew/cask/tcl-tk 8.6.9_1 is already installed
    To upgrade to 8.6.10, run brew upgrade homebrew/cask/tcl-tk

相关博文

About rainbird

IOS攻城狮
This entry was posted in Mac and tagged , , , , , , , , , . Bookmark the permalink.

发表评论