macOS Mojave:从 High Sierra 更新到 Mojave 后无效的活动开发者路径

macOS Mojave: invalid active developer path after updating to Mojave from High Sierra

升级到 macOS Mojave 后,我尝试从终端 运行 GIT,但它一直给我以下错误:

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

之前它工作正常。

打开终端,然后运行以下内容:

xcode-select --install

这将下载并安装 xcode 开发者工具并解决问题。问题是需要明确同意许可协议。作为后续步骤,您可能需要将路径重置为 Xcode 如果您有多个版本或希望命令行工具为 运行 而没有 Xcode.

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

xcode-select --switch /Library/Developer/CommandLineTools

我也找到了这个问题的答案

https://apple.stackexchange.com/questions/254380/macos-mojave-invalid-active-developer-path

这条线对我有用。我遇到过同样的问题。 运行 它在终端中。

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

当我在终端中使用 git 时:

然后我运行它:

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

更新 XCode 到 12.3

后,我遇到了这种情况

以 root 身份使用以下命令解决了问题:

sudo xcode-select --reset