OMG!我的 Homebrew 🍺 壞掉了

Lai Yen Ju
4 min readOct 29, 2019

--

為了將原本安裝在電腦內的 Python 升級為 Python3,選擇用 Homebrew 安裝 Python3,才發現 Homebrew 壞掉,在安裝過程中出現許多錯誤訊息,所以展開修復 Homebrew 的作業,我將修復 Homebrew的過程記錄下來,作為參考。

兵荒馬亂的起始點,就在終端機輸入 brew install python3 指令開始安裝 Python3 後,終端機給我下列訊息:

Error: An unexpected error occurred during the `brew link` step
The formula built, but is not symlinked into /usr/local
Permission denied @ dir_s_mkdir - /usr/local/FrameworksError: Permission denied @ dir_s_mkdir - /usr/local/Frameworks

為了瞭解問題發生的原因,以及可能的解決方法,我在終端機輸入 brew doctor 進行診斷,結果獲得以下結果。主要是缺少了某些資料夾,導致 Homebrew 安裝 python 與 node 出現問題:

Warning: The following directories do not exist:/usr/local/sbinYou should create these directories and change their ownership to your account.  sudo mkdir -p /usr/local/sbin
sudo chown -R $(whoami) /usr/local/sbin
Warning: You have unlinked kegs in your Cellar.Leaving kegs unlinked can lead to build-trouble and cause brews that depend onthose kegs to fail to run properly once built. Run `brew link` on these:pythonWarning: Some installed formulae are missing dependencies.
You should `brew install` the missing dependencies:
brew install node

依照上述顯示結果的指示,依序在終端機執行

  • sudo mkdir -p/user/local/sbin
  • sudo chown -R $(whoami) /usr/local/sbin
  • brew link --overwrite node
  • brew link --overwrite python

輸入完上述命令後,問題即可解決。可再次執行 brew doctor 確定修復狀況,得到下列顯示結果,確定已修復完畢。

Your system is ready to brew. 撒花~🎉

後記

當 brew 指令執行下去後,從未遇過 Homebrew 出現問題的我,對螢幕顯示很長的結果感到非常緊張,當下最直接的反應就是複製得到的錯誤訊息,到 Google 查詢,找到以下兩則貼文內容,才得知解決方式:

但從以上貼文可知,只要在輸入 brew doctor後仔細閱讀終端機回傳的錯誤內容,就能按提示的步驟解決😁

--

--

Lai Yen Ju
Lai Yen Ju

Written by Lai Yen Ju

I’m a graduate student struggling in natural language processing. News media, design and programming are my favorite writing topics.

No responses yet