macOS "xcrun: error: invalid active developer path": fix it after a macOS update
Fix macOS "xcrun: error: invalid active developer path" when git, make or brew stop working: reinstall the Command Line Tools, or point xcode-select to Xcode.
by OhSudo ·
Yesterday everything worked. Today, usually after a macOS update, git, make, gcc or brew stop with this:
xcrun: error: invalid active developer path (/Library/Developer/CommandLineTools), missing xcrun at: /Library/Developer/CommandLineTools/usr/bin/xcrunOn a Mac, git and the other developer commands in /usr/bin are small launchers. They ask xcrun where the real tools live. The message says the configured folder has no tools in it: the update removed or broke them, or you deleted Xcode. Your projects and your Git repositories are fine.
TL;DR
xcode-select -p # which folder is configured?xcode-select --install # reinstall the Command Line ToolsA dialog opens; accept it and wait for the download. Then open a new terminal window and try git --version.
1. Reinstall the Command Line Tools
For most people this is all it takes:
xcode-select --installAccept the dialog. It’s a download of a few hundred megabytes up to a few gigabytes, depending on the version.
2. “command line tools are already installed”
xcode-select: error: command line tools are already installed, use "Software Update" in System Settings to install updatesThe folder exists but is broken, or the system thinks it’s fine. First try the update, which is the gentlest way:
softwareupdate --listsoftwareupdate --install "Command Line Tools for Xcode-16.4" # use the exact label from the listIf there’s nothing to install, remove the folder and start again. It holds only these tools, none of your work:
sudo rm -rf /Library/Developer/CommandLineToolsxcode-select --installWarning
Type that rm path exactly, and check it before you press Enter. /Library/Developer/CommandLineTools is safe to remove; a typo in a sudo rm -rf might not be.
3. You use the full Xcode
If xcode-select -p points to a Command Line Tools folder that’s gone, but Xcode is installed, or if it points to an Xcode that you moved or renamed, select the right one:
sudo xcode-select --switch /Applications/Xcode.app/Contents/Developersudo xcodebuild -license acceptXcode’s first launch after an update may also need its extra components: xcodebuild -runFirstLaunch.
If you deleted Xcode and only need the command line, go back to the tools:
sudo xcode-select --switch /Library/Developer/CommandLineToolsOr reset to the default: sudo xcode-select --reset.
4. Check it worked
xcode-select -pxcrun --versiongit --versionHomebrew has its own check, and it’s worth running after a macOS update, since formulas may need rebuilding:
brew doctorbrew update && brew upgrade5. In CI
On a macOS runner in GitHub Actions, this usually comes from a step selecting an Xcode version that isn’t installed on that image. List the installed ones with ls /Applications | grep Xcode, and select one of those.
Shell, we have a problem!
Similar, but different: xcrun: error: unable to find utility "simctl", not a developer tool or in PATH means the Command Line Tools are selected, but that tool comes only with the full Xcode. You have not agreed to the Xcode license agreements needs sudo xcodebuild -license accept. And xcrun: error: SDK "iphoneos" cannot be located also points to needing the full Xcode. For an app macOS won’t open, see is damaged and can’t be opened. npm modules that need the compiler fail with gyp ERR! until the tools are back.
Found this useful? Share it.
Found a mistake? Let us know at contact@ohsudo.com.