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


当前回答

我刚升级到High Sierra,我不能运行xcode-select -install。首先,我必须从应用商店安装xcode。然后我运行xcode-select——install。然后我必须运行sudo xcodebuild -license,同意条款,然后我终于可以再次运行git命令。

其他回答

重新分配Xcode配置的路径对我有用。

sudo xcode-select -switch /Applications/Xcode.app

然后可能会提示您(在尝试命令后)同意许可协议。

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

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

更新到macOS 10.13.3后

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

我刚升级到High Sierra,我不能运行xcode-select -install。首先,我必须从应用商店安装xcode。然后我运行xcode-select——install。然后我必须运行sudo xcodebuild -license,同意条款,然后我终于可以再次运行git命令。