macOS Sonoma – Fixing ‘Invalid Active Developer Path’ Error for Git

developmentgitmacosxcode

After upgrading to macOS Big Sur, I tried to run git from Terminal but it kept giving me the following error:

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

How do I fix it?

Best Answer

Solution

Open Terminal, and run the following:

xcode-select --install

This will download and install the Command Line Tools package and fix the problem.

You do not need Xcode, you can install only the Command Line Tools here, it is about 130Mb.

If the above alone doesn't do it, then also run:

xcode-select --reset

Further reading

The problem is that one needs to explicitly agree to the license agreement. As a follow on step, you may need to reset the path to Xcode if you have several versions or want the command line tools to run without Xcode.

xcode-select --switch /Applications/Xcode.app
xcode-select --switch /Library/Developer/CommandLineTools

I found the solution in this question, Command Line Tools not working.

You may get an error message: "Can't install the software because it is not currently available from the Software Update server". In this case xcode-select --reset works as pointed by akozin.