13
votes

After upgrading to macOS Mojave, 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.

Previously it was working fine.

4
Possibly the Xcode Command Line Tools have been removed. You could try running: xcode-select --install or if you want to use the Xcode installation instead, running sudo xcode-select --switch /Applications/Xcode.app/Contents/Developer - msbit
If I remember correctly, by git is distributed along with the developer/xcode package on mac. Try starting xcode, if it asks to accept a license or download an update, select yes. - ikkentim
This is the wrong site for this Q but 1s on google searching "macos mojav invalid active developer path" would reveal the answer in the first link: apple.stackexchange.com/questions/254380/… - Dominic

4 Answers

24
votes

Open Terminal, and run the following:

xcode-select --install

This will download and install xcode developer tools and fix the problem. 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 have also found the solution in this question.

https://apple.stackexchange.com/questions/254380/macos-mojave-invalid-active-developer-path

1
votes

This line worked for me. I had the same issue. Run it in the terminal.

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

when I use git in the terminal:

ErrorImage

then I run it:

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

This happened to me after updated XCode to 12.3

Using the following command as root solved the issue:

sudo xcode-select --reset