2208

After upgrading to macOS Monterey, 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?

6
  • 47
    I was really confused that the question is 5 years old but says "after upgrading to macOS Monterey," which was released less than a month ago. Then I checked the edit history and it looks like you're updating it with each new release. Good on you, sir.
    – Travesty3
    Nov 8, 2021 at 17:03
  • 20
    You sir are a real gentlemen! Doing this for 5 years, and updating your question, amazing!
    – Tancho
    Nov 8, 2021 at 18:06
  • 4
    @Tancho Thank you sir :)
    – The Onin
    Nov 9, 2021 at 0:55
  • 3
    @Travesty3 haha me the same. I just joined appleExchange only to upvote.
    – jabujavi
    Nov 9, 2021 at 10:51
  • 1
    Wow! You kept updating this question for 5 years? This is the best post I have seen so far on Apple Stack Exchange
    – Nicholas
    May 4 at 21:00

7 Answers 7

3067
+150

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:

sudo 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.

sudo xcode-select --switch /Applications/Xcode.app
sudo 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.

9
  • 4
    I also had to run sudo xcodebuild -license accept
    – a113nw
    Dec 29, 2020 at 19:07
  • 1
    solved my "Can't install the software" issue that occured with sudo xcode-select --install.
    – jerik
    Feb 11, 2021 at 23:51
  • 4
    It happens after updating macOS from Bigsur to Monterey.
    – anaszaman
    Nov 3, 2021 at 12:00
  • 19
    "218 hours remaining" wtf... :O :D :D
    – OZZIE
    Nov 25, 2021 at 18:51
  • 1
    No need to download Xcode. I am using MacOS Monterey version 12.x. I have downloaded "Command Line Tools for Xcode 13.3 beta". Restarted terminal and command line is working along with github clone/pull/push issues. It worked like charm.
    – Kamlesh
    Feb 5 at 9:10
91

If you don't want to install nor use Xcode (I don't) you can install only command tools for Xcode (please see Edit)

Preconditions:

  • you have AppleID

Solution

Go to https://developer.apple.com/download/more/ and find Command line tools OS X 10.11) for Xcode 7.1. Then install downloaded .dmg package.

Newer versions

It should work with newer versions of Command line tools OS X however I tested it Command line tools OS X 10.11) for Xcode 7.1 particular version.

Update to macOS 10.13

After updating do macOS 10.13, I had to install Command Line Tools (macOS 10.13) for Xcode 9 - also works great.


Edit

As @setholopolus mentioned in comment,

xcode-select --install

Also installs only command line tools for Xcode.

You can also verify this at: http://osxdaily.com/2014/02/12/install-command-line-tools-mac-os-x/

I am leaving my answer in case you'd have problems with installation via cli.


PS credits to this SO answer: https://stackoverflow.com/a/33593066/2029818

1
  • 1
    I am using MacOS Monterey version 12.x. I have downloaded "Command Line Tools for Xcode 13.3 beta". Restarted terminal and command line is working along with github clone/pull/push issues. Your solution worked like charm. Thanks a lot dear.
    – Kamlesh
    Feb 5 at 9:09
52

For macOS High Sierra, just run the same command:

xcode-select --install

and everything will get back to work.

2019 UPDATE: This is needed for every new macOS version, so it'll work for Catalina as well.

0
32

Here are the steps I needed to go through for Mojave:

First xcode-select --reset.

Next I needed to upgrade xcode tools to the latest version: sudo softwareupdate -ia --verbose (NB: this runs all available updates from the app store, there is a way to specify that you only want to update one app/program, but I don't know it off the top of my head).

You can try this command another time if it shows some inconsistent behaviour during the first try.

Finally verify that it worked by using a git command of your choosing, e.g. git status.

1
  • 1
    softwareupdate -l will show a list like * Label: Command Line Tools for Xcode-13.2 and then you can pick the specific one by using the text after * Label:, e.g. softwareupdate --install "Command Line Tools for Xcode-13.3"
    – jaygooby
    Apr 13 at 10:27
22

I tried the xcode-select --install but I was forced to install it from the App Store.

Then all git stuff ran smoothly.

18

xcode-select --install and xcode-select --reset didn't work for me.

I had to download it manually from Apple Developers website: https://developer.apple.com/download/

Choose the Command line of your current OS.

Screenshot for link

2
15

The accepted answer is correct, but also note that git does not make it obvious if the error is coming from remote or from local. If you are running OS X on your remote, your install problem may be on the remote side and you'll see the same error on git clone and git pull but NOT on git status.

0

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .