How to Fix "xcrun error invalid active developer path" with Git on macOS


I ran an update on macOS and came across this error when running a git pull command.

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

The issue is that Xcode Command-line Tools needs to be installed or updated, and we need to explicitly agree to the license agreement.

Solution 1: Xcode not installed

via the command line

First, let’s open the terminal and run this install command.

xcode-select --install

We’ll see this output: xcode-select: note: install requested for command line developer tools.

And then we should be prompted with another window to confirm this action.

Once the install completes, we can open a new terminal to test our git commands.

If the problem persists, we can attempt running a reset afterward.

sudo xcode-select --reset

via the Apple Developer download page

If xcode-select --install can’t find the software, we can download the command line tool manually.

Let’s head over to the Apple Developer’s Download Page. We’ll be prompted to sign up or log in.

We can search for the appropriate Command Line Tools for (macOS xx.x) Xcode xx.x and download the .dmg file.

Solution 2: Xcode installed

If we have Xcode installed, we can skip the install and force the terminal to use Xcode’s Command-line tools.

sudo xcode-select --reset
sudo xcodebuild -license