1. 程式人生 > >Homebrew 安裝以及更新源替換

Homebrew 安裝以及更新源替換

安裝xcode

如果安裝app store裡面的xcode,會發現很大(6G多)
在終端執行:

xcode-select --install

如果沒有安裝過xcode,會彈出個視窗,點選安裝即可,如下圖:

在這裡插入圖片描述

安裝後再重新執行xcode-select --install會出現如下結果:
在這裡插入圖片描述

Homebrew 安裝

/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

在這裡插入圖片描述
在不翻牆的情況下,安裝可能有些慢。

Homebrew 更新源

當使用Homebrew下載應用時,會發現很慢,可以換成國內的更新源。

Homebrew的更新源由三部分組成:本體(brew.git)、核心(homebrew-core.git)以及二進位制預編譯包(homebrew-bottles),需要對這個三個部分,分別進行設定。

# 替換brew.git:
$ cd "$(brew --repo)"
# 中國科大:
$ git remote set-url origin https://mirrors.ustc.edu.cn/brew.git
# 清華大學:
$ git remote set-url origin https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/brew.git

# 替換homebrew-core.git:
$ cd "$(brew --repo)/Library/Taps/homebrew/homebrew-core"
# 中國科大:
$ git remote set-url origin https://mirrors.ustc.edu.cn/homebrew-core.git
# 清華大學:
$ git remote set-url origin https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/homebrew-core.git

# 替換homebrew-bottles:
# 中國科大:
$ echo 'export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.ustc.edu.cn/homebrew-bottles' >> ~/.bash_profile
$ source ~/.bash_profile
# 清華大學:
$ echo 'export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.tuna.tsinghua.edu.cn/homebrew-bottles' >> ~/.bash_profile
$ source ~/.bash_profile

# 應用生效:
$ brew update

更新源完成後,下載應用時,會顯示更新源的地址,如下圖所示:
在這裡插入圖片描述

參考連結

最後的最後

						有啥問題,歡迎進群交流技術: 363034250