homebrew安裝方法1
操作步驟
1.復(fù)制首頁紅框中的url到瀏覽器打開(需要梯子):https://raw.githubusercontent.com/Homebrew/install/master/install.sh

2.保存腳本到本地brew_install.sh
3.打開終端至腳本目錄執(zhí)行
bash brew_install.sh
原文:http://www.itdecent.cn/p/b1de316fc3fc
homebrew最新國內(nèi)源安裝方法2
前言
因?yàn)橐恍┰蛐遁d了homebrew,但是用官網(wǎng)的安裝方法很慢且容易中斷,想用國內(nèi)的源進(jìn)行安裝。網(wǎng)上大部分的方法都是
cd ~
curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install >> brew_install
1
2
然后修改源后,用ruby進(jìn)行安裝。但是這個(gè)地址已經(jīng)被“取締”了,在瀏覽器輸入這個(gè)地址顯示以下內(nèi)容:
!/usr/bin/ruby
STDERR.print <<~EOS
Warning: The Ruby Homebrew installer is now deprecated and has been rewritten in
Bash. Please migrate to the following command:
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"
EOS
Kernel.exec "/bin/bash", "-c", '/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"'
1
2
3
4
5
6
7
8
9
10
Homebrew國內(nèi)源安裝
cd ~
curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh >> brew_install
1
2
在終端中用curl復(fù)制地址內(nèi)容,或者直接從瀏覽器上輸入地址后復(fù)制內(nèi)容,然后修改BREW_REPO的值
BREW_REPO="https://github.com/Homebrew/brew"
BREW_REPO="git://mirrors.ustc.edu.cn/brew.git"
1
2
修改保存后,執(zhí)行以下命令后會(huì)快速進(jìn)行安裝
/bin/bash brew_install
1
安裝的中間會(huì)卡在
Cloning into '/usr/local/Homebrew/Library/Taps/homebrew/homebrew-core'...
1
這時(shí)候直接Ctrl+C結(jié)束,通過ustc的源進(jìn)行配置
mkdir -p /usr/local/Homebrew/Library/Taps/homebrew/
cd /usr/local/Homebrew/Library/Taps/homebrew
git clone https://mirrors.ustc.edu.cn/homebrew-core.git
1
2
3
配置完成后終端輸入brew help顯示幫助信息則說明安裝成功,如果提示失敗請(qǐng)檢查/usr/local/bin下是否有brew,有的話添加環(huán)境變量即可
Homebrew Cask安裝
Homebrew Cask需要用homebrew進(jìn)行安裝,同樣建議修改homebrew的鏡像源為ustc源(或者國內(nèi)其他源)。如果是按照上面的方法安裝的homebrew,鏡像源應(yīng)該已經(jīng)是ustc的源,用下面的命令查看。
查看brew鏡像源
git -C "$(brew --repo)" remote -v
查看homebrew-core鏡像源
git -C "$(brew --repo homebrew/core)" remote -v
查看homebrew-cask鏡像源(需要安裝后才能查看)
git -C "$(brew --repo homebrew/cask)" remote -v
1
2
3
4
5
6
如果是https://github.com/Homebrew/brew.git的源,需要進(jìn)行修改:
修改brew鏡像源
git -C "$(brew --repo)" remote set-url origin https://mirrors.ustc.edu.cn/brew.git
修改homebrew-core鏡像源
git -C "$(brew --repo homebrew/core)" remote set-url origin https://mirrors.ustc.edu.cn/homebrew-core.git
修改homebrew-cask鏡像源(需要安裝后才能修改)
git -C "$(brew --repo homebrew/cask)" remote set-url origin https://mirrors.ustc.edu.cn/homebrew-cask.git
更新
brew update
1
2
3
4
5
6
7
8
順便附上恢復(fù)源的地址:
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
brew update
1
2
3
4
修改源之后,輸入:
brew install brew-cask-completion
1
安裝完成后輸入brew cask help測(cè)試,如果出現(xiàn)一下內(nèi)容并卡住
Cloning into '/usr/local/Homebrew/Library/Taps/homebrew/homebrew-cask'...
1
同樣的方法,通過ustc的源進(jìn)行配置
cd /usr/local/Homebrew/Library/Taps/homebrew
git clone https://mirrors.ustc.edu.cn/homebrew-cask.git
1
2
再輸入brew cask help測(cè)試,應(yīng)該就會(huì)顯示幫助信息,接著按照上面的方法修改homebrew-cask鏡像源即可。
————————————————
版權(quán)聲明:本文為CSDN博主「WizardtoH」的原創(chuàng)文章,遵循 CC 4.0 BY-SA 版權(quán)協(xié)議,轉(zhuǎn)載請(qǐng)附上原文出處鏈接及本聲明。
原文鏈接:https://blog.csdn.net/WizardtoH/java/article/details/104744008