我刚刚从优胜美地升级到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,从来没有。 有人有办法吗?


当前回答

在macOS 10.14中,如果安装了两个或多个版本,也可能出现此问题。如果你喜欢xCode GUI,你可以通过进入首选项- CMD +,选择位置选项卡并选择命令行工具的版本来实现。请参考附件的打印画面。

其他回答

更新到macOS 10.13.3后

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

在莫哈韦沙漠

卸载旧版本的命令行工具:

sudo rm -rf /Library/Developer/CommandLineTools

下载并安装命令行工具10.14 Mojave

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

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

更新到High Sierra 10.13.2

xcode-select—install ALONE不适合我。

从应用商店下载X-code xcode-select美元,安装 a.安装后可能需要在命令行中使用softwareupdate进行更新。$sudo softwareupdate -i "命令行工具(macOS High Sierra version 10.13) for Xcode-9.1" $sudo xcodebuild -license

对我来说,在我删除了Xcode之后,我必须切换活动开发人员路径,如下所示: Sudo xcode-select -s /