Xcode Command Line Tools

Written & tested for accuracy by a developer (not AI)

xcrun: error: invalid active developer path

'xcrun: error: invalid active developer path' means the Xcode Command Line Tools are missing or damaged, often after a macOS upgrade. Here's how to fix it.

The Xcode Command Line Tools are Apple's package of developer tools for the terminal. The Homebrew package manager and most programming languages need them.

Fixing the Command Line Tools is one step in keeping your Mac ready for development. See the Mac development setup guide.

Before you get started

To fix this error, I recommend using our free app to reinstall the Xcode Command Line Tools. It is a FREE Mac app that installs the Command Line Tools, configures your shell, installs Homebrew and Git, and verifies everything works. It does everything this guide covers, but easier and faster. Here are all the details about the app before you download. Then:

If you're fixing the tools yourself, here is a guide.

What the error means

You'll usually see the error when you run Git or another developer command in your terminal application:

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

The git, make, and clang commands in /usr/bin are stand-ins. When you run one, it asks a tool named xcrun to find the real command in the active developer folder. You set that folder with the xcode-select command. The error means the active developer folder is set, but it is missing parts that xcrun needs.

The message names usr/bin/xcrun, but a working Command Line Tools folder on a current macOS doesn't contain that file. So don't check for it to decide whether your tools are damaged. Use the check below instead.

The path in parentheses tells you which folder macOS is looking in. It is usually /Library/Developer/CommandLineTools, the Command Line Tools folder. It can also be a folder inside the full Xcode app, if you set Xcode as the active developer folder.

Common causes:

  • A macOS upgrade left the Command Line Tools folder in place but removed some of its contents.
  • The Command Line Tools folder was deleted.
  • The Xcode app was moved or deleted while it was the active developer folder.

First steps to fix it

First, check the macOS version. If you're running an older version, update macOS to the latest macOS version.

Check the active developer folder

Ask xcode-select which folder is active. Then ask xcrun to find the clang compiler. Homebrew runs the same check when it starts. If the tools work, each command shows a path.

With the Command Line Tools as the active developer folder, you'll see:

$ xcode-select -p
/Library/Developer/CommandLineTools
$ xcrun --find clang
/Library/Developer/CommandLineTools/usr/bin/clang

With the full Xcode app as the active developer folder, you'll see:

$ xcode-select -p
/Applications/Xcode.app/Contents/Developer
$ xcrun --find clang
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang

If xcrun --find clang shows the xcrun: error message instead of a path, the folder is damaged. Go to the next step.

If xcode-select -p shows a folder inside Xcode, and you've moved or deleted Xcode, reset the active developer folder to the default:

$ sudo xcode-select --reset

Enter your Mac password when asked. Then run your command again. If you see the error again, go to the next step.

Install the Command Line Tools

Ask macOS to install the tools:

$ xcode-select --install

If an installer window opens, click Install and follow the steps. See xcode-select: note: install requested for command line developer tools if the install doesn't start.

If you see "Command line tools are already installed", the damaged folder is still in the way. macOS won't install over it. Remove the folder and install the tools again, as shown in Reinstall Xcode Command Line Tools.

Check that it works

Run the command that failed again:

$ git --version
git version 2.54.0 (Apple Git-157)

You'll see the Git version instead of the error. Your version number may differ. See Check if Xcode Command Line Tools Are Installed for more ways to check the tools.

Related messages

On a Mac with Apple Silicon, you may see a similar error that starts with xcrun: error: unable to load libxcrun and mentions incompatible architecture. It means the Command Line Tools folder holds tools built for Intel Macs, for example a folder carried over from an older Intel Mac. The fix is the same: remove the folder and install the tools again, as shown in Reinstall Xcode Command Line Tools.

If a command asks you to install the tools instead of showing this error, see Error xcode-select no developer tools were found.

Continue setting up your Mac

Don't miss the full visual roadmap and checklist that shows how to set up a Mac for software development, with all the essential tools and settings you might not yet know about.