Some Mac Terminal users may discover git, pip, HomeBrew, and other command line tools may fail or not work as intended with an error message stating “xcrun: error: invalid active developer path (/Library/Developer/CommandLineTools)”. Sometimes these command line tools stop working after a macOS system software update, but they worked previously.
Fortunately it’s easy to fix the “xcrun: error: invalid active developer path (/Library/Developer/CommandLineTools)” error message, and get git, pip, Homebrew, or whatever other command line tool that failed, to start working again.
For what it’s worth, the full error message is:
xcrun: error: invalid active developer path (/Library/Developer/CommandLineTools), missing xcrun at: /Library/Developer/CommandLineTools/usr/bin/xcrun
Fix “xcrun: error: invalid active developer path” Error in Terminal on MacOS
The solution, as you may have guessed from the error message itself, is to reinstall or install Command Line Tools. Yes, even if you already have command line tools installed, you should reinstall it to resolve the error message, particularly if you are only experiencing the error after a system software update (eg, from Mojave to Monterey).
Installing/reinstalling CLT can be done from the command line by issuing the following command string in Terminal:
Hitting return will cause a pop-up to appear with a progress indicator on the download for Command Line Tools.
Once the installation of Command Line Tools has completed, you should reboot the Mac (sometimes simply refreshing, relaunching Terminal, or opening a new Terminal may resolve the ‘xcrun error invalid active developer path’ message too, but a reboot is recommended).
If you are using Homebrew, you should also be sure to update Homebrew after you have (re)installed Command Line Tools.
Still seeing xcrun: error: invalid active developer path (/Library/Developer/CommandLineTools)?
If you installed or reinstalled command line tools through Terminal, rebooted the Mac, and you’re still getting the error, you can also try to manually install Command Line Tools by using a DMG file directly from Apple.
You will need an Apple ID to access the download, then just head to developer.apple.com and download Command Line Tools for Xcode (latest version) and install it manually.
Again, Homebrew users will want to update Homebrew. You should not have to install Homebrew again or remove it and then reinstall it, a simple update should do the trick.
Did this work to resolve your issues with git, pip, Homebrew, or whatever was triggering the xcrun error message at the command line on your Mac? Did you find another solution? Share your thoughts and experiences in the comments.