Xcode命令行工具无法定位git

11
在 Big Sur 上,我安装了 XCode CLT,但没有安装 xcode 本身。Git 运行正常。 然后我安装了 XCode,现在当我尝试运行 git 时,会出现以下消息:
git: error: Failed to determine realpath of '/Library/Developer/CommandLineTools/SDKs/MacOSX10.14.sdk' (errno=No such file or directory)
git: error: sh -c '/Applications/Xcode.app/Contents/Developer/usr/bin/xcodebuild -sdk /Library/Developer/CommandLineTools/SDKs/MacOSX10.14.sdk -find git 2> /dev/null' failed with exit code 16384: (null) (errno=No such file or directory)
xcode-select: Failed to locate 'git', requesting installation of command line developer tools.

弹出一个窗口,要求安装CLT,我点击“确定”后,它会下载并安装几分钟。但是当它完成时,我又回到了起点。
/Library/Developer/CommandLineTools/SDKs/MacOSX10.14.sdk不存在,但存在10.1511.111.3的目录,但没有10.14

2个回答

46

运行以下命令:

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

5
我又对最近针对 macOS 12.6 和 Xcode 14 的安全补丁进行了工作。 - David Krider
2
太好了。刚刚安装了Ventura,运行得非常顺畅!! - Vijay Kumar Kanta

1

我有过同样的经历。解决方法是启动Xcode并完成第一次运行。在此过程中,它会下载一些东西,之后git就正常了。

我收到了与你相同的错误消息块,但在上面或下面的行中,有一个提示建议运行xcodebuild -runFirstLaunch,我认为这将具有手动运行Xcode的第一次相同的效果。


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