"xcrun: error: invalid active developer path" after a macOS update
· 5 min read
If git, make or clang suddenly prints “xcrun: error: invalid active developer path,” macOS is pointing at developer tools that are missing or no longer valid. After a major macOS update that’s usually the Command Line Tools. Run xcode-select --install in Terminal, click Install in the dialog that opens, wait for it to finish, then run your command again.
What the message means
Programs like git, make, clang and python3 in /usr/bin aren’t the real tools. They’re stand-ins that ask xcrun to find the real one inside the active developer directory. The xcode-select man page lists these stand-ins, and git and make are among them.
When that directory is gone or empty, xcrun has nothing to run and prints a message like this:
xcrun: error: invalid active developer path (/Library/Developer/CommandLineTools), missing xcrun at: /Library/Developer/CommandLineTools/usr/bin/xcrun
The path in the brackets varies. It’s /Library/Developer/CommandLineTools when the standalone Command Line Tools are the active choice, and a path inside Xcode.app when Xcode is. The wording after “missing xcrun at:” repeats that path with /usr/bin/xcrun on the end.
A major macOS update can leave the Command Line Tools missing or unusable, which is why the error tends to show up right after one. The tools can also fall out of step with the OS: an Apple engineer on Apple’s developer forums explains that on a beta release of macOS you need the matching beta of the tools.
Find out what is active
Ask which directory macOS is using:
xcode-select -p
It prints one path. Then ask where git really lives:
xcrun --find git
On a working Mac that prints a full path. On this Mac, with Xcode installed and active, the two commands print:
/Applications/Xcode.app/Contents/Developer
/Applications/Xcode.app/Contents/Developer/usr/bin/git
If xcrun --find git prints the error instead, the active directory is damaged or missing, and one of the fixes below applies. Which one depends on what xcode-select -p printed.
Fix one: install the tools
This is the fix when the path is /Library/Developer/CommandLineTools, or when you don’t use Xcode.
- Open Terminal and run:
xcode-select --install
- A dialog asks: “The “xcode-select” command requires the command line developer tools. Would you like to install the tools now?” Click Install.
- Click Agree on the Command Line Tools License Agreement, and wait for the download to finish. How long it takes depends on your connection, so don’t trust a time estimate from elsewhere.
- Run
git --versionto confirm. A version number means it’s fixed.
Once the tools are installed, Software Update (System Settings, General, Software Update) offers new versions of them as updates. It isn’t a dependable place to get them the first time, so use the Terminal command.
If the installer says the software isn’t currently available from the Software Update server, or the install fails, update macOS fully and try again. If that still fails, or you’re on a beta macOS, download the Command Line Tools package that matches your macOS from the Downloads page at developer.apple.com (sign in with your Apple Account and search for Command Line Tools) and open it like any installer.
Fix two: point macOS back at Xcode
If you have Xcode and xcode-select -p printed a path that no longer exists (Xcode was moved, renamed or deleted), tell macOS where it is now. This needs an administrator password, since it affects every user on the Mac:
sudo xcode-select --switch /Applications/Xcode.app/Contents/Developer
The man page also accepts /Applications/Xcode.app and works out the rest. If you keep more than one copy of Xcode, a beta next to a release, this same command picks which one the command line tools use.
Fix three: reset the choice
If you removed Xcode and want macOS to find the Command Line Tools by itself again, clear the setting:
sudo xcode-select --reset
Per the man page, this unsets any developer directory you chose, so macOS goes back to its default search. Run xcode-select --install afterward if the tools aren’t there.
If it’s still broken
When xcode-select --install says the tools are already installed but the error continues, the folder is probably damaged. Apple’s own instruction for uninstalling the Command Line Tools is to remove that folder; after that, install them fresh. Look at it first; on a working Mac it holds Library, SDKs and usr, and nothing of yours:
ls /Library/Developer/CommandLineTools
Then remove it (this asks for your administrator password) and reinstall:
sudo rm -r /Library/Developer/CommandLineTools
xcode-select --install
Paste the path exactly as shown. A typo in a sudo rm command can delete something you need.
You can also test Xcode in one command without changing the Mac. The DEVELOPER_DIR environment variable overrides the active directory for whatever runs with it, which confirms Xcode is fine before you run --switch:
DEVELOPER_DIR=/Applications/Xcode.app/Contents/Developer git --version
Things that look the same but aren’t
- A license prompt. If you use full Xcode, a message about the Xcode license agreement is a different problem. It needs you to accept the terms, not install anything: open Xcode once, or run
sudo xcodebuild -license, which shows the agreement in Terminal. - Homebrew warnings. Homebrew can complain that the Command Line Tools are outdated even when everything works. That warning comes from Homebrew, not from
xcrun. - “command not found.” That means the program isn’t installed or isn’t on your PATH. See zsh: command not found for how to tell.
If you manage a developer Mac, the settings developers change first on a new machine covers what else is worth checking, and why Xcode eats the disk covers the other common surprise.
Questions
Why did git stop working after I updated macOS?
git in /usr/bin is a stand-in that needs the Command Line Tools or Xcode to do the real work. A major macOS update often removes or invalidates them, so the stand-in has nothing to hand off to. Reinstalling the tools restores it.
Do I need to install all of Xcode?
No. The Command Line Tools alone give you git, make, clang and the rest. Full Xcode is only needed for building apps in Xcode itself. Either one clears the error.
Is it safe to run xcode-select –install? Yes. It opens an Apple installer dialog for the tools and changes nothing else. It needs your confirmation before it downloads anything.
Will the error come back after the next macOS update?
It can. Major updates are the usual trigger, so after one, run git --version once. If it prints the error again, repeat the install.