xcode command line tools not able to locate git

5.3k Views Asked by At

On Big Sur, I had XCode CLT installed, but not xcode itself. Git was working fine. Then I installed XCode and now when I try to run git I get the following message:

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.

A popup comes up, asks to install CLT and when I say ok, it downloads and installs for a few minutes. But when it's done, I'm right back where I started.
/Library/Developer/CommandLineTools/SDKs/MacOSX10.14.sdk does not exist, but there are directories for 10.15, 11.1 and 11.3. But not 10.14.

2

There are 2 best solutions below

3
On BEST ANSWER

Run the command:

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

I had the same experience. The solution was to launch Xcode and complete that first run. It downloaded some stuff as part of the process and git was fine after that.

I was receiving the same block of error messages you were, but in either the line above or below was a tidbit suggesting to run xcodebuild -runFirstLaunch which I suspect would have had the same effect as manually running Xcode that first time.