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?

  • 1
    I don't think it was an issue pre Big Sur unless you have more info. What version of Xcode have you got and how did you install the command line tools
    – mmmmmm
    Mar 12 at 13:16
  • 1
    @mmmmmm I'm currently on Big Sur v11.2.1, and like I stated in the post, I have tried installing command line tools via the popup that appears when something tries to access it (like git init) and via the xcode-select --install command. I have the CommandLineTools directory so I'm pretty sure it is installed, but everything keeps asking me to install again.
    – RPatel99
    Mar 12 at 18:16
  • 1
    @MarcWilson I understand, but I repeatedly install CLT over and over again, and it still thinks it isn't installed. For example, if I type in git init it will fail because it thinks CLT is missing, so a popup will prompt me to install it. If I accept, wait for it to install, and then run git init again, the exact same thing happens. Restarting the Mac after installing CLT doesn't change anything either.
    – RPatel99
    Mar 12 at 18:18
  • 1
    @MarcWilson Just tested it out, and it still doesn't work. I removed the CommandLineTools directory, reinstalled with xcode-select --install, and then tried to git init and I got the same error as before (failed to locate 'git', requesting installation of command line developer tools), and a popup asking me to install CLT again... running xcode-select --install did re-add the CommandLineTools directory, so that part works, but something else must be causing the issue...
    – RPatel99
    Mar 12 at 21:36
  • 1
    Were you able to fix this issue? I'm facing the very same problem running make from a GoLang program @RPatel99
    – Leonardo
    Apr 28 at 15:49

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.

You must log in to answer this question.

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