我刚刚从优胜美地升级到El Capitan(并复制了从El Capitan升级到Sierra的问题),当我尝试在终端内键入例如git状态时,我得到以下错误:

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

我没有安装Xcode,从来没有。 有人有办法吗?


当前回答

对于最新版本Mojave 10.14.1,我使用

解决从https://developer.apple.com/download/more/下载”登录苹果id,并下载

命令行工具最新稳定版本

这样一切都能正常工作

老答案

xcode-select --install

对我没用。

其他回答

如果你对xcode-select——install命令有问题;例如,我一直得到一个网络问题超时,然后尝试下载dmg developer.apple.com/downloads(命令行工具OS X 10.11)的Xcode 7.1

更新到macOS 10.13.3后

更新macOS 10.13后,我必须安装 用于Xcode 9.3的命令行工具(macOS 10.13) 下载网址:https://developer.apple.com/download/more/

在升级到macOS Catalina后,我也遇到了同样的问题。 这对我不起作用:

xcode-select --install

下载并安装Xcode 12的命令行工具就做到了!

对于最新版本Mojave 10.14.1,我使用

解决从https://developer.apple.com/download/more/下载”登录苹果id,并下载

命令行工具最新稳定版本

这样一切都能正常工作

老答案

xcode-select --install

对我没用。

我将mac os升级到macOS High Sierra - 10.13.3,在尝试安装watchman(使用命令酿造安装watchman)时遇到了类似的问题。

运行命令:xcode-select——install,然后运行"brew install watchman" -一切正常!