今天在 MacBook 上安裝 Homebrew,結果中間斷了網,想從新卸載重裝,結果一直卸載失敗。問題現象以下:git
卸載時錯誤以下:github
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/uninstall)" Failed to locate Homebrew!
重裝時錯誤以下:ruby
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" It appears Homebrew is already installed. If your intent is to reinstall you should do the following before running this installer again: ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/uninstall)" The current contents of /usr/local are bin Cellar etc Frameworks Homebrew include lib opt sbin share var
google 後發現有這樣的問題討論帖子,有人建議執行:bash
rm -rf /usr/local/.git
後再從新安裝。貌似這個解決方案有不少人成功了。不過我這麼作後仍是出現卸載失敗。app
粗粗想了一下,大概由於是斷網形成的,斷網致使了安裝不徹底,在安裝目錄產生了一些不完整的目錄文件。
查找了一下,找到一個目錄
執行:curl
mdfind homebrew
找到:this
/usr/local/Homebrew
cd
到/usr/local/
目錄,ls -al
了一下,發現還存在幾個安裝時出現過的目錄名字,因而一併刪除了。google
下面是當初安裝時的提示信息:url
➜ local ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" ==> This script will install: /usr/local/bin/brew /usr/local/share/doc/homebrew /usr/local/share/man/man1/brew.1 /usr/local/share/zsh/site-functions/_brew /usr/local/etc/bash_completion.d/brew /usr/local/Homebrew ==> The following new directories will be created: /usr/local/Cellar /usr/local/Homebrew /usr/local/Frameworks Press RETURN to continue or any other key to abort
下面是 ls -al
的信息:code
➜ local ls -al total 0 drwxr-xr-x 13 Ade wheel 442 9 12 19:15 . drwxr-xr-x@ 12 root wheel 408 12 5 2015 .. drwxrwxr-x 2 Ade admin 68 9 12 19:15 Cellar drwxrwxr-x 2 Ade admin 68 9 12 19:15 Frameworks drwxrwxr-x 3 Ade admin 102 9 12 19:15 Homebrew
刪除 Homebrew 安裝時產生的目錄
rm -rf Cellar Frameworks Homebrew
從新執行安裝命令:
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
按照提示 回車
繼續執行,
最後出現下面的提示表示安裝成功
==> Installation successful! ==> Next steps Run `brew help` to get started Further documentation: https://git.io/brew-docs ==> Homebrew has enabled anonymous aggregate user behaviour analytics Read the analytics documentation (and how to opt-out) here: https://git.io/brew-analytics
執行 brew help
,正常顯示命令幫助,Nice !