MacOS missing xcrun问题

升级MacOS后brew upgrade经常会出现如下错误:

1
2
3
4
5
The bottle needs the Apple Command Line Tools to be installed.
You can install them, if desired, with:
xcode-select --install

xcrun: error: invalid active developer path (/Library/Developer/CommandLineTools), missing xcrun at: /Library/Developer/CommandLineTools/usr/bin/xcrun

是因为系统升级后没有安装相应版本的Apple Command Line Tools
解决办法就是像错误提示里说的一样:

1
$ xcode-select --install