一開始安裝,在官網上的命令:java
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"
特別的慢,並且執行着就很容易斷開,鏈接不上。因此須要換一種方法。git
打開終端,到本身喜歡的文件夾,執行如下命令,把install文件拉取下來,而且更名爲brew_install.shgithub
curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh >> brew_install.sh
而後使用命令行,打開文件,修改裏面的配置:vim
cd brew_install.sh
按i
編輯,找到bash
BREW_REPO = 「https://github.com/Homebrew/brew「
替換成下面的:curl
BREW_REPO = "https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/brew.git"
按esc
,輸入 :wq
,保存退出。學習
而後把這個文件拖入終端中,回車,而後就會出現一個權限的問題。url
permission denied: ...
須要在文件夾的目錄下,執行如下命令:spa
chmod 777 brew_install.sh
執行完以後,再把文件拖到終端中,而後,回車,執行,再而後就卡住了。命令行
而後須要關掉終端,進入/user/local/Homebrew/Library/
文件夾下,刪除Taps文件夾,執行如下命令:
git clone git://mirrors.ustc.edu.cn/homebrew-core.git/ /usr/local/Homebrew/Library/Taps/homebrew/homebrew-core --depth=1
而後執行如下命令便可:
cd $(brew --repo) git remote set-url origin https://mirrors.ustc.edu.cn/brew.git cd "$(brew --repo)/Library/Taps/homebrew/homebrew-core" git remote set-url origin https://mirrors.ustc.edu.cn/homebrew-core.git
所有換成科大的源應該使用下面的命令,實測只使用前面三個命令,仍是特別卡。
# 替換 Homebrew 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 # 替換 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.ustc.edu.cn/homebrew-bottles' >> ~/.zshrc source ~/.zshrc 下面能夠安安靜靜的安裝了:
下面是安裝brew cask的步驟,先更新
brew update
輸入如下命令:
brew install caskroom/cask/brew-cask
而後若是報錯了,就換一個命令:
brew install brew-cask-completion
驗證如下是否是成功安裝:
brew cask
或者執行
brew tap caskroom/cask
再接着就被卡主了...欲哭無淚,而後解決方法和以前的同樣,終端命令行。全都是坑...
cd "$(brew --repo)/Library/Taps/" cd homebrew git clone https://mirrors.ustc.edu.cn/homebrew-cask.git
而後再執行換源:
cd "$(brew --repo)"/Library/Taps/homebrew/homebrew-cask git remote set-url origin https://mirrors.ustc.edu.cn/homebrew-cask.git
更新
brew update && brew upgrade && brew cleanup
btw,brew search
已經集成了brew cask search
功能,因此別使用brew cask search
。
此文章僅表明本身(本菜鳥)學習積累記錄,或者學習筆記,若有侵權,請聯繫做者刪除。人無完人,文章也同樣,文筆稚嫩,在下不才,勿噴,若是有錯誤之處,還望指出,感激涕零~
技術之路不在一時,山高水長,縱使緩慢,馳而不息。
公衆號:秦懷雜貨店,有問題能夠留言