Issue
After a major macOS upgrade (currently to Ventura) the command line tools, including git, in the terminal windows (Terminal, iTerm) stop working. We get the error message
xcrun: error: invalid active developer path (/Library/Developer/CommandLineTools), missing xcrun at: /Library/Developer/CommandLineTools/usr/bin/xcrun
Cause
The macOS terminals use the Xcode Command Line Tools to execute commands on the Mac. When you upgrade the Macintosh operating system, you need to accept the licensing agreement of the Xcode Command Line Tools.
Solution
The simplest way to do it, to re-install the Xcode Command Line Tools and click the Accept button.
- Open a terminal window and execute
xcode-select --install
- The installation starts, and when prompted, Accept the license terms and complete the installation.
Troubleshooting
- If after the re-installation you still get the same error message, try to execute
sudo xcode-select --reset