git, clang or xcrun stops working because the active developer folder is gone
xcrun: error: invalid active developer path (/Library/Developer/CommandLineTools), missing xcrun at: /Library/Developer/CommandLineTools/usr/bin/xcrunShort answer
The folder that xcode-select points to no longer holds developer tools, so xcrun, git, clang and make cannot start. Print the selected path with xcode-select -p, then either install the command line tools with xcode-select --install or switch the path to a full Xcode with sudo xcode-select --switch.
Fix it fast
1Find out which cause you have
Print the folder the system is using and check whether it exists. The path in the error is the same one; what matters is which of the two cases you are in: a Command Line Tools folder that is empty or missing, or an Xcode.app path that no longer exists.
xcode-select -p ls "$(xcode-select -p)/usr/bin" | head -52Match what you see, then jump to its fix
- 1
xcode-select -p prints /Library/Developer/CommandLineTools and listing that folder fails or shows no usr/bin/xcrunThe Command Line Tools package is not installed any moreFix - 2
xcode-select -p prints a path ending in /Contents/Developer, such as /Applications/Xcode-beta.app/Contents/Developer, and that folder does not existThe selected path points to an Xcode.app that was moved, renamed or deletedFix - 3
xcode-select --install answers that command line tools are already installed, yet xcrun still reports a missing path or missing toolThe Command Line Tools folder exists but is broken, and the installer says they are already installedFix
- 1
What does the error look like?
xcrun: error: invalid active developer path (/Library/Developer/CommandLineTools), missing xcrun at: /Library/Developer/CommandLineTools/usr/bin/xcrunxcrun: error: invalid active developer path (/Applications/Xcode.app/Contents/Developer), missing xcrun at: /Applications/Xcode.app/Contents/Developer/usr/bin/xcrunThe same message printed when you run git, clang, make or swift from a terminal
Cause 1 of 3
The Command Line Tools package is not installed any more
1Check
Apple's technote lists /Library/Developer/CommandLineTools as the place the Command Line Tools package installs to. When the error names that folder, either the package was never installed on this macOS install or its contents were removed. Check that the folder holds the tools.
ls /Library/Developer/CommandLineTools/usr/bin | head -5
ls /Applications | grep -i xcode2Fix
Start Apple's installer for the tools, accept the prompt and wait for it to finish. If you have a full Xcode in /Applications you do not need this package: switch to Xcode instead (next cause).
xcode-select --install3Verify
xcrun can find a tool again and git prints its version.
xcrun --find git
git --versionConfirmed by developer.apple.com
Cause 2 of 3
The selected path points to an Xcode.app that was moved, renamed or deleted
1Check
xcode-select stores one developer directory for the whole Mac. If you removed the Xcode that was selected, or renamed it, the stored path keeps pointing at the old location. List the copies you really have and compare them with the printed path.
xcode-select -p
ls -d /Applications/Xcode*.app2Fix
Switch to an Xcode that exists. The command needs administrator rights and affects every user on the Mac. For one shell session only, set DEVELOPER_DIR instead of switching.
sudo xcode-select --switch /Applications/Xcode.app/Contents/Developer
# one terminal only, no sudo:
export DEVELOPER_DIR=/Applications/Xcode.app/Contents/Developer3Verify
The printed path now exists and xcodebuild reports a version.
xcode-select -p
xcodebuild -versionConfirmed by docs.flutter.dev
Cause 3 of 3
The Command Line Tools folder exists but is broken, and the installer says they are already installed
1Check
The installer refuses to run when it sees the folder, even if the folder is damaged. Apple's technote says the tools are removed by deleting /Library/Developer/CommandLineTools, so a damaged copy can be removed and installed again. If Xcode is installed, Apple notes that it bundles the tools, so remove nothing and use the previous cause.
xcode-select --install
ls -la /Library/Developer/CommandLineTools2Fix
Delete the damaged folder, then run the installer again and finish the prompt. This removes only the Command Line Tools package, not Xcode.
sudo rm -rf /Library/Developer/CommandLineTools
xcode-select --install3Verify
The folder is back with a usr/bin directory and the tools run.
ls /Library/Developer/CommandLineTools/usr/bin | head -5
xcrun --find clangConfirmed by developer.apple.com
How do I stop it coming back?
- Do not delete or rename the selected Xcode.app without switching xcode-select first.
- After a major macOS update, run xcode-select -p once and open Xcode once so its first-launch setup finishes.
- On CI, set DEVELOPER_DIR per job instead of relying on the machine-wide setting.
Sources
How was this page made?
I drafted this page with AI assistance from the official documents listed under Sources. Every cause above names the document that confirms it. I have not reproduced this fix on a machine of my own yet, so read it as documented guidance, not a test report. Found a mistake? Tell me.
Which stack is behind this page?
Projects of mine built on the same technologies:
Related fixes
Mobile apps
Simulator build fails because a library was built for real iPhones
building for iOS Simulator, but linking in object file built for iOS, for architecture arm64
The linker was building for the Simulator and met a library compiled only for physical iPhones.
4 causes, each with a fixMobile apps
UserDefaults logs 'Failed to read values in CFPrefsPlistSource' for an app group
Settings saved by the app are not visible to its extension, widget or sibling app that share the group
This log comes from the preferences system when UserDefaults is opened for an app group's suite.
3 causes, each with a fixMobile apps
iOS app crashes: Google Maps SDK must be initialized via provideAPIKey
Google Maps SDK for iOS must be initialized via [GMSServices provideAPIKey:...] prior to use
The Maps SDK throws this when a Maps object is created before GMSServices.provideAPIKey has run.
3 causes, each with a fixMobile apps
UIKit app crashes because it cannot find the storyboard
Could not find a storyboard named 'Main' in bundle NSBundle
UIStoryboard throws this exception when no storyboard file with that name exists in the bundle it searches.
3 causes, each with a fixMobile apps
Firebase on iOS asks for the FCM token before APNs has given one
Be sure to re-retrieve the FCM token once the APNS device token is set.
The Firebase Messaging SDK needs the APNs device token from iOS before it hands out an FCM token.
3 causes, each with a fixMobile apps
A test push from the Firebase console never shows up on the iPhone
didReceiveRegistrationToken prints a token, yet no notification arrives
When a console message is accepted but the iPhone stays silent, the break is between Firebase and APNs or inside the app.
4 causes, each with a fix