homebrew 安裝

homebrew安裝方法1

操作步驟

1.復(fù)制首頁紅框中的url到瀏覽器打開(需要梯子):https://raw.githubusercontent.com/Homebrew/install/master/install.sh

image

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)" 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
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

?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡(jiǎn)書系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容