How to fix the error “xcrun error invalid active developer path (/Library/Developer/CommandLineTools), missing xcrun at /Library/Developer/CommandLineTools/usr/bin/xcrun”

I recently upgraded to macOS Monterey. When I try to run git branch on terminal, I get the following error:

xcrun: error: invalid active developer path 
(/Library/Developer/CommandLineTools), missing 
xcrun at: /Library/Developer/CommandLineTools/usr/bin/xcrun
  1. Accepted Answer for macOS: Monterey

Accepted Answer for macOS: Monterey

Upgrade your command line tools using

xcode-select --install

This will open a new window and ask you to confirm the installation. It might take a long time to complete so make sure your computer is connected to a power source. Once the installation is complete, try again.

This should solve your problem. If it doesn’t work, you may need to run the following as well:

sudo xcode-select --reset

and

sudo xcodebuild -license accept

Speak Your Mind