I updated to macOS Mojave (this happens on Catalina update too, and seems to potentially occur on every major update thereafter)
This morning I navigated to my work’s codebase in the Command Line on my MacBook pro, typed in “git status” in the repository and received the error:
xcrun: error: invalid active developer path (/Library/Developer/CommandLineTools), missing xcrun at: /Library/Developer/CommandLineTools/usr/bin/xcrun
How do I fix git, and command line tools?
The problem is that Xcode Command-line Tools needs to be updated.
Go back to your terminal and enter:
You’ll then receive the following output:
xcode-select: note: install requested for command line developer tools
You will then be prompted in a window to update Xcode Command Line tools. (which may take a while)
Open a new terminal window and your development tools should be returned.
Addition: With any major or semi-major update you’ll need to update the command line tools in order to get them functioning properly again. Check Xcode with any update. This goes beyond Mojave…
After that restart your terminal
Alternatively, IF that fails, and it very well might…. you’ll get a pop-up box saying “Software not found on server”, see below!
and you hit
xcode-select --install and it doesn’t find the software, log into Apple Developer, and install it via webpage.
Log in or sign up here:
Look for: “Command Line Tools for Xcode 12.x” in the list of downloads
Then click the dmg and download.