1、官方位址
首先我們先到官方位址:https://brew.sh/
可以看到簡單的安裝步驟, 接下來講解一下, 如何安裝homebrew。
2、安裝步驟
1) 在終端上執行指令:/usr/bin/ruby -e “$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)”
會輸出這句話:Press RETURN to continue or any other key to abort
這裡直接按Enter鍵繼續。
2)輸出密碼
接下來就會出現這個, 輸出你mac 密碼
==> /usr/bin/sudo /bin/chmod u+rwx /usr/local/bin /usr/local/etc /usr/local/lib /usr/local/share /usr/local/share/doc /usr/local/share/man /usr/local/share/man/man1
Password:
接下來會拉去很多版本的資訊, 你可能會在下面的地方停住。
等待合并就好。
3)完成
當你看到下面的資訊就說明完成了
==> Next steps:
- Run
brew help
to get started
3、可能出現的問題
brew install XXX一直卡在Updating Homebrew
方法1: 關閉更新, 在bash_profile加入關閉參數
解決方法,關閉自動更新,
vim ~/.bash_profile
export HOMEBREW_NO_AUTO_UPDATE=true
方法2: 更換鏡像源
1)跟換
替換brew.git:
cd "$(brew --repo)"
git remote set-url origin https://mirrors.ustc.edu.cn/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://mirrors.tuna.tsinghua.edu.cn/homebrew.git
中科大鏡像源: http://mirrors.ustc.edu.cn/homebrew.git
2) 還原
如果換了還是不行, 切回來,使用代理或者是網佳地方在更新
重置brew.git:
cd "$(brew --repo)"
git remote set-url origin https://github.com/Homebrew/brew.git
重置homebrew-core.git:
cd "$(brew --repo)/Library/Taps/homebrew/homebrew-core"
git remote set-url origin https://github.com/Homebrew/homebrew-core.git
4、經驗
有時一緻卡着, 我們使用ctrl + c 終止, 在使用之前安裝的工具, 有可能已經安裝成功了, 隻是在下載下傳其他的更新而已。