背景
其實就是想裝個powershell,然後發現需要安裝homebrew
好吧,安,結果,又發現超時,超時,超時
之後,你懂的,百度,百度,百度……
結果,過時的帖子,過期的方法……
唉,人笨,沒辦法,最後死活安上了,做個記錄,要不過2天又忘了
開整
正常安裝
嗯,開shell,粘上,回車,等着就行
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
不正常的
沒辦法,苦等也是超時,自己動手吧
改腳本
可以看到,命令中是執行了一個 install 的腳本,那麼下載下來改改吧
#!/usr/bin/ruby
# This script installs to /usr/local only. To install elsewhere (which is
# unsupported) you can untar https://github.com/Homebrew/brew/tarball/master
# anywhere you like.
HOMEBREW_PREFIX = "/usr/local".freeze
HOMEBREW_REPOSITORY = "/usr/local/Homebrew".freeze
HOMEBREW_CORE_TAP = "/usr/local/Homebrew/Library/Taps/homebrew/homebrew-core".freeze
HOMEBREW_CACHE = "#{ENV["HOME"]}/Library/Caches/Homebrew".freeze
# **********下面這行,改成科大的源地址 ********************
# BREW_REPO = "https://github.com/Homebrew/brew".freeze
BREW_REPO = "https://mirrors.ustc.edu.cn/brew.git".freeze
# **********看上面 *************************************
# TODO: bump version when new macOS is released
MACOS_LATEST_SUPPORTED = "10.14".freeze
# TODO: bump version when new macOS is released
MACOS_OLDEST_SUPPORTED = "10.12".freeze
# no analytics during installation
ENV["HOMEBREW_NO_ANALYTICS_THIS_RUN"] = "1"
ENV["HOMEBREW_NO_ANALYTICS_MESSAGE_OUTPUT"] = "1"
# 下面還有很多,不粘了,看着累
再安裝
看着還行,好吧,回車,接着安
迷糊,怎麼又停了,原來還要安裝 homebrew-core,結果又去美帝下載了
好吧,你恨,我改
可以看到 clone 的路徑
/usr/local/Homebrew/Library/Taps/homebrew/homebrew-core
我們接着用科大的
git clone https://mirrors.ustc.edu.cn/homebrew-core.git /usr/local/Homebrew/Library/Taps/homebrew/homebrew-core
美滋滋……
檢查一下
brew doctor
brew update
終於是安上了
再戰 power shell
brew cask install powershell
醉了,還要用 homebrew-cask
行吧,要安裝的位置知道了,接着抱科大的大腿
git clone https://mirrors.ustc.edu.cn/homebrew-cask.git "$(brew --repo)"/Library/Taps/homebrew/homebrew-cask
這裏面的 $(brew --repo)
是 homebrew的安裝位置,也就是默認的 /usr/local/Homebrew
飛一般的感覺
接着 powershell
HOOOOOOOOO!!!!!!!!!!!!!,終於安上了
補充
Homebrew Core: 核心軟件倉庫,第一個報錯中的homebrew-core
Homebrew Cask: 提供 macOS 應用和大型二進制文件,第二個報錯中 homebrew-cask
Homebrew Bottles:預編譯二進制軟件包,這個我們沒用到,需要的可以看一下科大的說明
總結
- 這麼費勁的原因,大家都懂,沒辦法改變,只能想其它辦法嘍
- 新接觸 MAC 的生態,瞭解的不多,踩坑是必然的
- 百度大叔啊,廣告挺厲害,就是搜出來的東西靠譜的越來越少
- 各位大神麻煩以後出解決方案的時候說明一下你的系統環境與適配的版本