Repeatedly Being Asked to Install Command Line Tools

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?


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


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.