How to fix “active developer path does not exist” with git on macOS

- by

I’ve recently removed Xcode from my ageing MacBook. Ever since then, I’m getting an error when I try to run git from the command line. The error goes something like this:

xcrun: error: active developer path ("/Library/Developer/CommandLineTools") does not exist

That’s because Xcode had installed several command line tools provided by Apple, and one of them was Git. I thought simply installing it via Homebrew would do the trick but alas that too brings up an error message, albeit a different one. Somewhat frustrated, I was wondering how I was ever going to run Git from the command line again.

I did some testing and found a fix to this issue. Here’s what worked for me.

Turns out that I had a symbolic link (or rather a stub) at /usr/bin/git, a place at which git might indeed be expected to live. This however redirected to a no longer existent Xcode installation, or more precisely the xcrun command. All I had to do was rename the symbolic link with admin privileges:

sudo mv /usr/bin/git /usr/bin/git-apple

Once that was taken care of, I could download the macOS installer from the official Git-SCM website. I found it under Downloads (it’s not the GUI version, just the command line version at the top of the page). It’s a .pkg file that will install git to /usr/local/git, and places symlinks into /usr/local/bin and /usr/share/man/.

Lo and behold, after the quick and painless installation, I could simply type git from the command line and the above error was gone, and git was operational again.



If you enjoy my content, please consider supporting me on Ko-fi. In return you can browse this whole site without any pesky ads! More details here.

Leave a Comment!

This site uses Akismet to reduce spam. Learn how your comment data is processed.