macOS missing xcrun after upgrade

How to resolve the infamous missing xcrun error

Thu Oct 26 2023

Just upgraded macOS? Seeing an xcrun error?

xcrun: error: invalid active developer path (/Library/Developer/CommandLineTools)

I just upgraded to macOS Sonoma and had exactly this. I noticed it when VS Code could not access git tools so I checked in my terminal and sure enough, trying the git command displayed the dreaded xcrun error above!

Not to worry, it's easy to fix.

The fix

Simply reinstall the XCode CLI tools by running the following command in your terminal and accepting the terms.

xcode-select --install

If things still aren't working after this, you can try forcing the CLI tools to reset. (You'll need sudo for this one).

sudo xcode-select -reset

And that's it! Hopefully now git and other developer tools package with XCode will be working again.