Fix: xcrun: error: invalid active developer path After macOS Update

Fix: xcrun: error: invalid active developer path After macOS Update

Written by

in

Quick answer: Your macOS update removed or invalidated the active Command Line Tools, so the xcrun shim that git calls no longer exists. Reinstall the tools with xcode-select --install, or download the matching Command Line Tools package from Apple Developer, then open a new terminal and reboot if prompted. If the path is stale, reset it with sudo xcode-select --reset.

Why this happens

On macOS, git is often not a standalone binary. It is a shim that calls xcrun, and xcrun looks up tools through the active developer directory. After a major macOS update, that directory can be removed, replaced, or left pointing at a Command Line Tools installation that no longer contains usr/bin/xcrun.

That produces the exact error:

xcrun: error: invalid active developer path (/Library/Developer/CommandLineTools), missing xcrun at: /Library/Developer/CommandLineTools/usr/bin/xcrun

The message is not a git bug. It means the active developer path is /Library/Developer/CommandLineTools, but the tools at that path are missing or incomplete. The same thing can happen if full Xcode was moved or deleted, or if xcode-select still points at an old Xcode location.

A pending Xcode license agreement can also block the tools after an update. In that case macOS may prompt you to agree before git works again.

How to fix it

1. Reinstall Command Line Tools with xcode-select

This is the first fix to try. In Terminal, run:

xcode-select --install

You should see:

xcode-select: note: install requested for command line developer tools

A macOS installer window should appear. Let it finish, then open a new Terminal window and test:

git --version

If git still fails, restart the Mac. A reboot is sometimes required to complete the Command Line Tools installation and stop the installer from prompting in a loop.

You can also check which developer path is active:

xcode-select -p

If it prints /Library/Developer/CommandLineTools and git --version works, you are done.

2. Download the matching Command Line Tools package

Sometimes xcode-select --install cannot find the package on the software update server. You may see an error like:

Can't install the software because it is not currently available from the Software Update server.

In that case, install the tools manually from Apple Developer:

  1. Go to developer.apple.com/download/all.
  2. Sign in with your Apple ID and complete two-factor authentication.
  3. Search for Command Line Tools for Xcode.
  4. Download the version that matches your macOS version and Xcode version.
  5. Open the .dmg, run the installer, and reboot if prompted.

Stable releases are the safer choice for normal development work. Beta Command Line Tools are intended for testing against beta SDKs.

After installing, open a new Terminal window and run git --version again. If the installer keeps reappearing, reboot before retrying.

3. Reset a stale developer path

If the tools are installed but xcode-select points at the wrong place, reset the path. First check it:

xcode-select -p

Then reset it:

sudo xcode-select --reset

Open a new Terminal window and test git again.

If you have full Xcode installed and want to use its developer tools, point the path at the Xcode app instead:

sudo xcode-select --switch /Applications/Xcode.app/Contents/Developer

Adjust the path if Xcode is installed somewhere else. Then run:

xcodebuild -runFirstLaunch

If you only want the standalone Command Line Tools, point back to them:

sudo xcode-select --switch /Library/Developer/CommandLineTools

That switch only works if the Command Line Tools are actually installed at that location.

4. Accept the Xcode license

After some updates, macOS requires you to accept the Xcode license before command-line tools work. Run:

sudo xcodebuild -license

Scroll to the end with the space bar, type agree, and press Return. If you prefer the non-interactive form, use:

sudo xcodebuild -license accept

Then open a new Terminal window and try git status again.

5. Check for a broken Xcode installation

If you use full Xcode and recently moved it, renamed it, or deleted it, xcode-select may still point at the old location. Run xcode-select -p and confirm the path exists. If it does not, switch to a valid Xcode path or reinstall Command Line Tools and reset the path as shown above.

How to prevent it

  • After every major macOS update, run xcode-select -p and git --version before starting work.
  • Keep Command Line Tools updated alongside Xcode.
  • Do not delete /Library/Developer/CommandLineTools manually.
  • If you use full Xcode, keep xcode-select pointed at the Xcode app you actually use.
  • Keep the Apple Developer downloads page bookmarked and have your Apple ID and MFA device ready.
  • Reboot after installing Command Line Tools if the installer prompts again or git still fails.

FAQ

Do I need to install full Xcode to fix git?

No. The standalone Command Line Tools package includes git and xcrun. Full Xcode also provides these tools, but it is a much larger download and is not required just to get git working again.

Why did this happen after a restart instead of an update?

A restart can expose a stale developer path or complete a pending tools removal. macOS may also decide to show the license agreement after restarting. The fix is the same: reinstall or update Command Line Tools, reset the path if needed, and accept the license.

Can I just run xcode-select --reset?

It only resets the selected developer path. If the Command Line Tools are missing, resetting the path will not restore xcrun. Install the tools first, then reset or switch the path if it still points at the wrong location.

Sources & credits

Parts of this guide are adapted from content licensed under CC BY-SA 4.0; this article is shared under the same license.