I updated to macOS Mojave (this happens to Catalina update too).
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
The problem is that Xcode Command-line Tools needs to be updated.
Go back to your terminal and hit:
xcode-select --install
You'll then receive:
xcode-select: note: install requested for command line developer tools
You will be prompted at this point 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
This fixed the issue I had with Microsoft Visual Studio Code which was complaining about Git not being installed when I first launched it after upgrading to Mojave. I thought the issue was VS Code, but it was the issue in this SO question. Restarting VS Code after installing the Xcode Command-line Tools solved the issue.
I wish the Xcode update was part of the OS update. Something like this happens every time I upgrade. Annoying.
Definitely annoying though. A simple check for Xcode installation and then an update during the OS update would be pretty simple to add. It's always something with these OS updates from Apple. You'd think they'd have figured it out by now.
For anyone using Git in PHPStorm; you need to restart PHPStorm after running
xcode-select --install
. Then it'll work.This solution works for me for Mac Catalina update also. Superb!!!