When I'm doing various development-related activities (such as initializing a git repository or installing packages in RStudio), I get repeatedly asked to install command line developer tools, even though I already have it installed.

I have a directory at /Library/Developer/CommandLineTools which contains Library,SDKs, and usr folders.

If I go along with the popup and install command line tools (again), the popup simply appears again if I attempt whatever I was doing before (like initializing a git repo).

I've attempted running xcode-select --install, but I get an error saying

Failed to locate 'clang', requesting installation of command line developer tools

and then that previously mentioned popup for installing command line tools reappears. I'm currently running MacOS Big Sur, but I'm fairly certain this was still an issue on the previous OS. Any suggestions on how I can fix this?


12 Answers 12


The following command worked

sudo xcode-select -switch /Library/Developer/CommandLineTools
  • 1
    thank you so much. this solved it for me on macOS Sonoma
    – drussell
    Commented Apr 3 at 12:53

This issue happened on my MacBook Air M1 machine after update macOS Monterey 12.6 released recently and installing Xcode CLI tools version 14.0. If you use command line tools like Homebrew, you might have received the following error (the part below is just an excerpt of it):

clang: error: sh -c '/Applications/Xcode.app/Contents/Developer/usr/bin/xcodebuild -sdk /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk -find clang 2> /dev/null' failed with exit code 34304: (null) (errno=Invalid argument)
xcode-select: Failed to locate 'clang', requesting installation of command line developer tools.

Then you are told that you need to install additional tools, in my case clang.

Here is the fix:

  1. Open Xcode app
  2. Select the platforms you may or may not develop with (depends if you are actually an iOS/macOS developer or if you just use the CLI tools such as myself). Choose as few as possible as these take hard disk space!
  3. Click download.
  4. Close and re-open your Terminal and try your CLI tools again. That's it!

Keep in mind, tools for the platforms you chose will be downloaded in the background, which might take a bit.

Update! Sep 9, 2022 It seems the issue is not related to the architecture of the mac (M1 or Intel) or the Xcode version!

Update! Nov 23, 2022 Keep in mind that the Xcode tools when opening Xcode after further updates will need to be updated, but in my experience this should NOT affect the CLI tools.

  • 1
    I was facing this issue on a M1 MacBook Air and your steps fixed it! Super annoying issue and I kept downloading and installing following the prompts.
    – dniviE
    Commented Sep 14, 2022 at 11:58
  • 2
    Coming back to this as it appears to have solved the issue with the prompt, but when going to System Preferences > Software Updates or running softwareupdate -l I am still being asked to install command line tools for Xcode 13.2, 13.4 and 14.0. No idea why, tried installing them all and it keeps coming back.
    – dniviE
    Commented Sep 15, 2022 at 10:15
  • 2
    It’s not related to 12.6 specifically – I just had the issue on my Mac Studio, which is still on 12.5.1 and hasn’t had any major updates installed for at least a month. I didn’t install or change anything Xcode-related recently, but this is a fairly new machine, and I don’t know if or when Xcode 14 was installed at all. Commented Sep 18, 2022 at 11:01
  • 1
    I'm getting this issue on both an M1 Macbook Air and a non-M1 Macbook Pro
    – user98513
    Commented Sep 29, 2022 at 9:03
  • 3
    I am also still being asked to install CLT for Xcode 13.2, 13.4 and 14.0, even after opening XCode or running xcodebuild -runFirstLaunch. My clang issue is fixed though. It does seem to have happened after upgrading to 12.6
    – renaudg
    Commented Oct 2, 2022 at 21:40

I think there are many different reasons this issue can occur, and so there are many different possible solutions. However, what worked for me was opening XCode -> Preferences -> Locations, and then setting Command Line Tools to the current version of XCode (version 12.5 at the time of this post, located at /Applications/Xcode.app for me). For whatever reason, there was no version selected until I manually set it via XCode Preferences.

  • This worked for me, and the others did not. Commented Apr 5 at 1:38

Based on the thread in superuser I ran

xcodebuild -runFirstLaunch

That fixed the problem for me.

  • This worked for me as well (after upgrading to macOS 12.6) Commented Sep 26, 2022 at 14:36
  • This worked for me with Intel MacBook Pro 2020 (MacOS 12.6 Monterey).
    – Max Malysh
    Commented Oct 13, 2022 at 19:29

Well I closed and opened Xcode again, it asked for an upgrade that I did and it all started working. Looks like they force you to update xcode tools by making your git stop working.

  • 2
    Just ran into this issue this morning, this worked for me
    – Don P
    Commented Sep 13, 2022 at 17:23

It happened after I updated my OS to Monterey 12.6 from 12.5

Fix- quit all terminal, IntelliJ wherever you are using shell. Now open Xcode application, It will update or install something. exit Xcode application and boom. your git problem is fixed. Enjoy !!

  • Your answer could be improved with additional supporting information. Please edit to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers in the help center.
    – Community Bot
    Commented Sep 13, 2022 at 19:10

The instrument command is deprecated in Xcode 13. Now you can use xcrun xctrace list devices to list devices.


Installing manually from this link solved my problem:

I figure when Xcode can’t tell if the tools are installed from the gui, it’s easier than issuing xcode-select commands to pull down the package and start the installation.

  • What do you mean by manually? Can you pls describe in more detail because the the OP owner indicates, s/he's tried doing it manually, i.e. through the macOS command line interface, a.k.a. the Terminal app.
    – Alper
    Commented Sep 12, 2022 at 23:53
  • When i said manually, i mean just go that link (developer.apple.com/download) and install command line tools from there Commented Sep 14, 2022 at 2:23

Had the same issue after migrating from Intel MacBook Pro —> M1 MacBook Pro. Tried doing the accepted solution, but Xcode wouldn't open at all anymore.

Reinstalling Xcode fixed these issues for me.

  1. Open Launchpad and search for "Xcode"
  2. Click and hold the Xcode icon till an "x" appears
  3. Click the "x" and then click Delete
  4. Open the App Store and search for "Xcode"
  5. Install Xcode again
  6. Open Xcode
  7. Click Install if asked "Install additional required components?"
  8. After installation is complete, you can quit Xcode
  9. Go to System Preferences —> Software Update
  10. Click Update Now if there's an update available for Command Line Tools for Xcode
  11. Restart Terminal / iTerm

I met a similar issue. It just prompted again and again and installed again and again. I open Xcode and continue the installation. It was just gone.

So it may be a simple update installation of the Xcode issue.


Sometimes it is asking again and again after reinstalling the command line using the command sudo xcode-select --install.

The solution that worked for me was to just open Xcode in my system and check if there are any updates required.

OS version - macOS Monterey 12.6

  1. Open Xcode
  2. If it will ask to install any component, just install it, else close the Xcode
  3. Now reopen your terminal and try git -v.

I had this same problem, but none of the solutions above worked for me.

tl;dr; the solution is to run

sudo cp -R /Library/Developer/CommandLineTools/SDKs/MacOSX12* /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/

which copies the older "MacOSX12" SDK into the Xcode 14 folders and seems to make everyone happy.

Why this is happening

The error I was seeing relating to the git binary was:

2022-11-14 16:33:18.828 xcodebuild[20025:1284001] Writing error result bundle to /var/folders/mc/tm26v4sd0pv1hncprqdff72h0000gn/T/ResultBundle_2022-14-11_16-33-0018.xcresult
xcodebuild: error: SDK "/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX12.3.sdk" cannot be located.
git: error: Failed to determine realpath of '/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX12.3.sdk' (errno=No such file or directory)
git: error: sh -c '/Applications/Xcode.app/Contents/Developer/usr/bin/xcodebuild -sdk /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX12.3.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.

In my case, Xcode updated to v14.1 and my Mac is running macOS 12.6. I'm not positive that those two things are related, but you can see above that the macOS SDK that xcodebuild is looking for is MacOSX12.3.sdk.

Running xcode-select -p returns /Applications/Xcode.app/Contents/Developer, which is what Xcode 14 configured automatically. (Changing this via sudo xcode-select --switch /Library/Developer/CommandLineTools fixes git, but breaks other things in subtle ways (like some CocoaPods commands).) enter image description here

The key here seems to be to copy the older, "missing" macOS SDK version into the Xcode folder structure so that everyone is happy.

Ideally, there would be some way to just have git point to the updated macOS SDK version, but I haven't figured that one out yet. Maybe upgrading to Ventura would fix that, but I haven't had the time to test that yet...

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .