在 MacOS Catalina 上 Git 无法工作: "xcrun: error: invalid active developer path (/Library/Developer/CommandLineTools), missing"

270
升级至 MacOS X 10.15 Catalina 后,我无法在终端运行任何 git 命令:
默认的交互式 shell 现在是 zsh。
要更新您的帐户以使用 zsh,请运行 chsh -s /bin/zsh
有关更多详细信息,请访问 https://support.apple.com/kb/HT208050
~ | git
xcrun:错误:无效的活动开发人员路径(/Library/Developer/CommandLineTools),缺少 xcrun 在:/Library/Developer/CommandLineTools/usr/bin/xcrun
chsh -s /bin/bash

我也重新启动了电脑。 然而,即使echo "$SHELL" 输出 /bin/bash,我仍然看到相同的消息。


Shell 与任何事情有什么关系?这似乎是 Xcode 命令行工具的问题。 - trojanfoe
2
已在https://apple.stackexchange.com/questions/254380/why-am-i-getting-an-invalid-active-developer-path-when-attempting-to-use-git-a/254381#254381回答。 - The Onin
1个回答

463

您需要重新安装命令行工具:

$ xcode-select --install

24
成功了!同时将 export BASH_SILENCE_DEPRECATION_WARNING=1 添加到您的 ~/.bash_profile 文件中,以摆脱烦人的提示信息。 - user6269864
21
请牢记这个命令。在升级 macOS 后解决开发问题时,它几乎总是正确的答案。 - idmean
43
xcode-select --reset是解决我的设备问题的方法。 - Mendel
8
sudo xcode-select --reset可以解决问题,但还需要同意条款和条件。命令是:sudo xcodebuild -license。 - David Hladky
1
可能可以通过运行 xcodebuild -runFirstLaunch 而不是提供的命令来规避许可协议。 - vhs
显示剩余8条评论

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接