Running git or make after a macOS update and getting "xcrun: error: invalid active developer path"? The Command Line Tools are missing or the pointer to them is stale. One command usually fixes it.
The Error
$ git status
xcrun: error: invalid active developer path
(/Library/Developer/CommandLineTools), missing xcrun at:
/Library/Developer/CommandLineTools/usr/bin/xcrun
The same error appears from gcc, clang, make, swift and anything else that routes through the developer toolchain.
Quick Fix
xcode-select --install
A dialog appears asking whether you want to install the command line developer tools. Click Install, accept the licence, and wait for it to finish. Then try your original command again.
That resolves the large majority of cases.
Why This Happens
macOS keeps a pointer to the active developer directory - the location of the toolchain that xcrun should use. You can see it with xcode-select -p.
A macOS upgrade frequently removes or replaces /Library/Developer/CommandLineTools without clearing that pointer. The result is a path that is still recorded as active but no longer contains xcrun, which is precisely what the error says.
This explains the symptom that confuses people most: git breaking overnight when no project changed. /usr/bin/git is not really git - it is a small shim that defers to xcrun to locate the real binary inside the active developer directory. Break the toolchain and every shim breaks together, which is why git, clang and make all fail at the same moment.
Fix 1: Reinstall the Command Line Tools
xcode-select --install
If the tools are genuinely absent, this downloads and installs them.
If it responds:
xcode-select: error: command line tools are already installed,
use "Software Update" to install updates
then the package is present but the pointer is wrong. Continue to fix 2.
Fix 2: Reset the Active Developer Path
Return the pointer to its default:
sudo xcode-select --reset
Or set it explicitly:
sudo xcode-select -s /Library/Developer/CommandLineTools
Check the result:
xcode-select -p
git --version
Fix 3: Point at Xcode Instead
If you have the full Xcode application installed, point the toolchain at it:
sudo xcode-select -s /Applications/Xcode.app/Contents/Developer
sudo xcodebuild -license accept
The licence step matters. An unaccepted licence produces a different but equally blocking error (Agreeing to the Xcode/iOS license requires admin privileges), and accepting it up front avoids a second round trip.
You do not need Xcode for general development. The Command Line Tools package is a few hundred megabytes and includes git, clang, make and the standard headers. Full Xcode runs to many gigabytes and is only necessary for building iOS and macOS applications.
Fix 4: Remove and Reinstall a Corrupt Toolchain
If the directory exists but is incomplete - a common outcome of an interrupted install - remove it and start again:
sudo rm -rf /Library/Developer/CommandLineTools
xcode-select --install
Check what you are about to delete first:
ls -la /Library/Developer/CommandLineTools
This path contains only Apple-supplied tooling. It holds none of your own work, so removing it is safe, but as with any recursive sudo rm it is worth reading the path twice before pressing Return.
Fix 5: When the Installer Refuses
Occasionally the GUI installer fails with:
Can't install the software because it is not currently available
from the Software Update server.
This means Apple's update catalogue and your macOS build are briefly out of step. Rather than retrying indefinitely, download the package directly:
- Go to the Apple Developer downloads site and sign in with any free Apple ID.
- Search for Command Line Tools for Xcode and choose the version matching your macOS release.
- Download the
.dmgand run the installer inside it.
Verify the Fix
# Where the toolchain now points
xcode-select -p
# The tools themselves
git --version
clang --version
xcrun --find git
Expected output:
/Library/Developer/CommandLineTools
git version 2.39.5 (Apple Git-154)
Apple clang version 15.0.0 (clang-1500.3.9.4)
/Library/Developer/CommandLineTools/usr/bin/git
xcrun --find git is the most direct confirmation: it exercises exactly the lookup that was failing.
Prevention
- Expect this after every major macOS upgrade. Running
xcode-select --installas part of your post-upgrade routine turns a confusing morning into a two-minute task. - Keep a note of whether your machine uses the standalone Command Line Tools or full Xcode. Mixed expectations are the usual reason a fix that worked on one Mac does nothing on another.
- If you manage Macs for a team, push the Command Line Tools through MDM after an OS upgrade rather than waiting for individual reports of broken git.
- Homebrew depends on this toolchain. If
brew installstarts failing with compiler errors after an upgrade, checkxcode-select -pbefore investigating the formula.
Summary
- First:
xcode-select --install - Already installed:
sudo xcode-select --reset - Have Xcode:
sudo xcode-select -s /Applications/Xcode.app/Contents/Developerthensudo xcodebuild -license accept - Corrupt:
sudo rm -rf /Library/Developer/CommandLineToolsthen reinstall - Verify:
xcode-select -pandxcrun --find git