Fix "xcrun: error: invalid active developer path" on macOS
xcrun: error: invalid active developer path (/Library/Developer/CommandLineTools), missing xcrun at: /Library/Developer/CommandLineTools/usr/bin/xcrun
- xcrun: error: invalid active developer path (/Applications/Xcode.app/Contents/Developer), missing xcrun at: /Applications/Xcode.app/Contents/Developer/usr/bin/xcrun
- xcode-select: note: No developer tools were found, requesting install.
- xcode-select: error: command line tools are already installed, use "Software Update" to install updates
- gyp: No Xcode or CLT version detected!
Apple's Command Line Tools (CLT) are missing or broken, often after a macOS update, while git, make or clang depend on them. Run xcode-select --install to reinstall them; if macOS says they are already installed, delete the /Library/Developer/CommandLineTools folder and run the install again.
What this error means
On macOS, /usr/bin/git, /usr/bin/make or /usr/bin/clang are only shims: they call xcrun, which looks for the real tool in the "active developer directory" chosen by xcode-select. That directory is either /Library/Developer/CommandLineTools or Xcode.app/Contents/Developer. If xcrun no longer exists there, all these commands fail with this message. It is typical after a major macOS update, which removes or invalidates the CLT, or after moving or deleting Xcode.
Common causes
- macOS update: the new version removed or invalidated the installed Command Line Tools.
- Xcode moved, renamed or deleted:
xcode-selectstill points to anXcode.app(orXcode-beta.app) that no longer exists. - Interrupted or incomplete CLT install: the folder exists but files are missing, hence the "already installed" message.
Step-by-step fix
-
Check the active directory
Check which folder
xcode-selectpoints to and whetherxcrunis actually there.xcode-select -p ls -l /Library/Developer/CommandLineTools/usr/bin/xcrun -
Reinstall the Command Line Tools
Start the install and confirm the window that opens. The download takes a few minutes. You can also use System Settings > General > Software Update if a CLT update is offered there.
xcode-select --install -
If macOS says "already installed"
Delete the CLT folder and run the install again. Copy the path exactly: this
sudo rm -rfcommand only removes the Command Line Tools, not your projects or Homebrew.sudo rm -rf /Library/Developer/CommandLineTools xcode-select --install -
If you use full Xcode
Point
xcode-selectto your Xcode, accept the license and finish the first-launch setup. Adjust the path if your Xcode has another name.sudo xcode-select --switch /Applications/Xcode.app/Contents/Developer sudo xcodebuild -license accept xcodebuild -runFirstLaunch -
Reset to the default path
If you are unsure what to point to,
--resetrestores the default path (Xcode if installed, otherwise the CLT).sudo xcode-select --reset -
Check that everything works
Open a new terminal and test the tools. If you use Homebrew,
brew doctorreports any remaining issues.xcrun --version git --version clang --version brew doctor
Did this fix work for you?
Confirm it in one click: it will rise for the next developers stuck on the same error.
Keep it from coming back
- After every major macOS update, run
xcode-select --installor check Software Update before getting back to work. - Avoid renaming or moving
Xcode.app; if you keep several versions, switch between them withxcode-select --switch.
Frequently asked questions
Do I need to install full Xcode?
No. For git, Homebrew, node-gyp or C/C++ compilation, the Command Line Tools are enough and much lighter. Full Xcode is only needed to build Apple apps or use the simulators.
Why did git stop working after a macOS update?
/usr/bin/git is a shim that goes through xcrun and the Command Line Tools. If the update removed them, git fails until you reinstall them.
Does reinstalling remove my Homebrew packages?
No. Homebrew packages live in /opt/homebrew (Apple Silicon) or /usr/local (Intel) and are not touched. Some compiled formulas may just need a brew reinstall.
Useful tools for this error
More Systems (Windows, macOS, Linux) errors
- Fix "command not found" and "is not recognized as an internal or external command"
- Fix "running scripts is disabled on this system" in PowerShell
- Fix "SSL certificate problem: unable to get local issuer certificate" (git, curl, pip, npm)
- Fix "user is not in the sudoers file. This incident will be reported."
- Fix "/bin/bash^M: bad interpreter: No such file or directory"
- Fix "E: Could not get lock /var/lib/dpkg/lock-frontend" (apt, Ubuntu, Debian)
- Fix "App is damaged and can't be opened" on macOS (Gatekeeper)