最近在 macOS 上使用 Homebrew 安裝套件時,我遇到了這個錯誤,我的情況是安裝 rbenv 時出現了以下錯誤訊息:

➜ brew install rbenv

...

Error: Your CLT does not support macOS 11.
It is either outdated or was modified.
Please update your CLT or delete it if no updates are available.
Update them from Software Update in System Preferences or run:
 softwareupdate --all --install --force

If that doesn't show you an update run:
 sudo rm -rf /Library/Developer/CommandLineTools
 sudo xcode-select --install

Alternatively, manually download them from:
 https://developer.apple.com/download/more/.

Error: An exception occurred within a child process:
 SystemExit: exit

很奇怪吧!

根據訊息中建議,我執行了 softwareupdate --all --install --force,但並沒有解決問題,所以我接著執行了 sudo rm -rf /Library/Developer/,然後執行了 sudo xcode-select --install

就是這樣。

這樣做之後,brew install rbenv 正常運作了。