我刚刚从优胜美地升级到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.13.3后

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

其他回答

我尝试了xcode-select -install解决方案,但它没有帮助我,我从Sierra更新到High,发生了这样的情况,我的解决方案:

sudo xcode-select --reset

更新到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 /

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

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

命令行工具最新稳定版本

这样一切都能正常工作

老答案

xcode-select --install

对我没用。

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