3482

I updated to the latest OS, and/or restarted my computer (this happens on every major update, but this time all I did was restart my computer on 2022-09-13).

This morning I navigated to my work's codebase in the command line on my MacBook Pro, typed in "git status" in the repository and received an error:

(In 9/2022, this error was much different, but I didn't capture it)

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

Git will not work!

How do I fix Git, and the command-line tools?

24
  • 13
    Possible duplicate apple.stackexchange.com/questions/254380/…
    – markroxor
    Commented Jul 1, 2019 at 5:28
  • 251
    to be honest, this problem is something APPLE should take care of. They create it, they should fix it !!!!! Asking everyone to run that command everytime this happens isn't an Good/Correct option. Not to mention you need to download that big chunk for git only.
    – windmaomao
    Commented Feb 4, 2021 at 14:30
  • 7
    I didn’t run into it on my update to Big Sur. Only had this problem the year when I originally wrote this Q&A. I’ve just been updating it every year to include the latest changes.
    – dustbuster
    Commented Feb 5, 2021 at 5:07
  • 15
    We should get paid by apple for debugging their code!
    – Nir
    Commented Apr 1, 2021 at 9:46
  • 33
    I updated to Monterey and faced the same issue. Apple really needs to look into this issue. Commented Nov 2, 2021 at 23:37

41 Answers 41

5058

The problem is that Xcode Command-line Tools needs to be updated due to a MacOs update.

  • Did not run into this on Sonoma.
    • Maybe Apple fixed the process?
  • Updated for Ventura

After opening the terminal after restarting, I tried to go to my code, and do a git status, and I got an error and prompt for command line software agreement:

So press space until you get to the [agree, print, cancel] option, so careful hit space to scroll down to the end, if you blow past It you have to run a command to get it back. Use sudo xcodebuild -license to get to it again.

Just be careful on scrolling down and enter agree and press return and it will launch into an update.

Xcode software license

Then I tried to use git after the install, and it prompted me to install Xcode tools again.

I followed my own advice from previous years (see below), and went to https://developer.apple.com/download/all and downloaded "Command Line Tools for Xcode 14" (You have to log in with your Apple ID and enter MFA code, so have all the devices you need for that handy. Then select "Command Line Tools for Xcode 14", or if you want to get into the alphas or betas, that's up to you. But stable releases are probably the best choice for software developers.

developer download page selection for "Command Line Tools for Xcode 14"

You have to either download the tools from CLI or the developer page and before you can use git, you need to reboot!!! Or you will get stuck in a loop of prompt & downloading

Rebooting will break the loop and complete the installation of your CLI tools including git so that you can get back to work

Solutions for previous years, these may or may not be valid these days as the downloads page has changed significantly:

PREVIOUS YEARS SOLUTIONS, probably #2 is most helpful.

*** Solution #1:

Go back to your terminal and enter:

xcode-select --install

You'll then receive the following output:

xcode-select: note: install requested for command line developer tools

You will then be prompted in a window to update Xcode Command Line tools. (which could take a while)

Open a new terminal window and your development tools should be returned.

Addition: With any major or semi-major update you'll need to update the command line tools in order to get them functioning properly again. Check Xcode with any update. This goes beyond Mojave...

After that restart your terminal

Alternatively, IF that fails, and it might.... you'll get a pop-up box saying "Software not found on server", proceed to solution 2.

*** Solution #2: (Preferred method)

If you hit xcode-select --install and it doesn't find the software, log into Apple Developer, and install it via webpage.

Log in or sign up here:

https://developer.apple.com/download/more/

Look for: "Command Line Tools for Xcode 14.x" in the list of downloads Then click the dmg and download. (See previous image above) either way, you will probably wind up at an apple downloads webpage.

63
  • 76
    This fixed the issue I had with Microsoft Visual Studio Code which was complaining about Git not being installed when I first launched it after upgrading to Mojave. I thought the issue was VS Code, but it was the issue in this SO question. Restarting VS Code after installing the Xcode Command-line Tools solved the issue.
    – Mark
    Commented Oct 10, 2018 at 0:36
  • 411
    I wish the Xcode update was part of the OS update. Something like this happens every time I upgrade. Annoying.
    – mvndaai
    Commented Dec 14, 2018 at 17:17
  • 25
    Definitely annoying though. A simple check for Xcode installation and then an update during the OS update would be pretty simple to add. It's always something with these OS updates from Apple. You'd think they'd have figured it out by now.
    – zgr024
    Commented Dec 14, 2018 at 20:53
  • 21
    For anyone using Git in PHPStorm; you need to restart PHPStorm after running xcode-select --install. Then it'll work. Commented Feb 13, 2019 at 7:20
  • 73
    This solution works for me for Mac Catalina update also. Superb!!! Commented Oct 8, 2019 at 16:55
387

I got some errors that the software was unavailable from the update server when trying

xcode-select --install

What fixed it for me was going here https://developer.apple.com/download/more/ and downloading Command Line Tools (macOS 10.14) for Xcode 10 and then installing it manually.

After that, the errors should be gone when you open up a new terminal.


Update for macOS Ventura 13.0.1 (Nov 2022)

Install Command Line Tools for Xcode 14.1

11
  • 15
    This should be the right answer, tried on 3 machines and @dustbuster answer doesn't work anymore and it shows "software was unavailable from the update server when trying" Commented Nov 2, 2018 at 14:17
  • 9
    For me this ends with software not available at server but @High6's answer below works. xcode-select --reset
    – briankip
    Commented Nov 4, 2018 at 14:59
  • downloading Command Line Tools (macOS 10.14) for Xcode 10.1 from the link. thanks! Commented Nov 4, 2018 at 21:33
  • 2
    Had xcode installed still there were issues. This worked like a charm... should be the selected answer. Or should be addendum to top answer.
    – AmitM
    Commented Nov 22, 2019 at 11:43
  • 2
    This also works for macOS 10.15.2. Though I had to select Command Line Tools for Xcode 11.3, since Xcode 10.1 wasn't available Commented Dec 13, 2019 at 21:04
180

For me xcode-select --reset was the solution on Mojave.

13
  • 7
    somehow, "xcode-select --install" ends of software not available at server. But this one works
    – Yan Zhu
    Commented Nov 1, 2018 at 4:32
  • This worked for me, I ran this command after installed new Xcode.
    – Sunho Hong
    Commented Sep 24, 2019 at 2:01
  • 5
    I just upgraded from Mac OS X 10.14 (Mojave) to MacOS 10.15 (Catalina) and faced this problem, this solution worked fine, it was no necessary to run xcode-select --install.
    – OJVM
    Commented Oct 22, 2019 at 22:19
  • 2
    works for me on Catalina as well, but needed to add sudo
    – gafi
    Commented Nov 6, 2019 at 10:58
  • 4
    sudo xcode-select --reset worked for me on a Mojave --> Catalina upgrade of MacOS Commented Dec 12, 2019 at 15:34
113

In addition to dustbuster's answer I needed to set path to the Xcode folder with this command:

sudo xcode-select -switch /Library/Developer/CommandLineTools
4
  • 2
    Yep same for me, @dustbuster might be a good idea to merge these answers.
    – James
    Commented Oct 19, 2018 at 19:30
  • Ok this one solved this for me. Tried xcode-select --install and downloading and installing manually, none of the solutions worked. Note that I waited and upgraded to version 10.14.1.
    – mpiktas
    Commented Nov 19, 2018 at 17:38
  • 4
    If you have Xcode installed, you do not need the separate command line tools install. Just make sure you run xcode-select --switch /Applications/Xcode.app/Contents/Developer or xcode-select --reset so Terminal will use the command line tools inside Xcode instead of the ones installed by the "command line tools" standalone installer. From then on, the App Store will auto-update Xcode and your tools will stay current.
    – uliwitness
    Commented Feb 15, 2020 at 10:51
  • been through so many answers, this is the one that worked for me after the Mojave update, thanks! Commented Aug 27, 2020 at 23:27
95

updated from Mojave to Big Sur and got the same error : the command

xcode-select --install

worked like a charm

65

After upgrade to Mac Catalina I faced the same issue, I had to run couple of commands to get this fixed.

First started with:

xcode-select --install

It didn't fix the problem, had to run the following in sudo

sudo xcode-select --reset

Then, finally got fixed after I switched and set the path explicitly for active developer directory:

sudo xcode-select -s /Library/Developer/CommandLineTools

Note: In case you have Xcode installed, you may need to specify Xcode directory in this case, it should be something like this

xcode-select -s /Applications/Xcode.app

3
  • If you have Xcode installed, you do not need the separate command line tools install. Just make sure you run xcode-select --switch /Applications/Xcode.app/Contents/Developer or xcode-select --reset so Terminal will use the command line tools inside Xcode instead of the ones installed by the "command line tools" standalone installer. From then on, the App Store will auto-update Xcode and your tools will stay current.
    – uliwitness
    Commented Feb 15, 2020 at 10:58
  • Xcode select did it since I only had the beta version installed!
    – gurehbgui
    Commented Aug 9, 2020 at 18:00
  • Try sudo xcode-select --reset first then --install Commented Nov 23, 2021 at 14:19
54

For me what worked is the following:

sudo xcode-select --reset

Then like in @High6's answer:

sudo xcodebuild -license

This will reveal a license which I assume is some Xcode license. Scroll to the bottom using space (or the mouse) then tap agree.

This is what worked for me on MacOS Mojave v 10.14.

4
  • your solution worked for me on MacOS 10.13 High Sierra. Thank you.
    – Daniel
    Commented Jan 1, 2020 at 19:46
  • If you have Xcode installed, this is the correct solution. Terminal will use the command line tools inside Xcode instead of the ones installed by the "command line tools" standalone installer. From then on, the App Store will auto-update Xcode and your tools will stay current.
    – uliwitness
    Commented Feb 15, 2020 at 10:54
  • This is working for BigSur as well as the Monterey beta branch. Way easier than downloading and installing giant new Xcode releases each time you update. Commented Jul 30, 2021 at 22:15
  • This did the trick for me and fixed VSCode not finding Git after I migrated from my old iMac running Catalina to my shiny new Apple Silicon MacBook Pro running Monterey via Migration Assistant. Commented Nov 13, 2021 at 9:30
54

If you use xcode then install it (~12GB)

xcode-select --install

Otherwise install latest command line tools (~500MB)

Downloads

Update: If struck in install loop

xcodebuild -runFirstLaunch
1
  • 3
    I've (re)installed xcode so many times over the past 2 years that it's like "How many times do I have to teach you this lesson, old man?" Commented Jul 2, 2021 at 2:06
53
  • if there are several versions, select one of them from: xcode -> Preferences and tap Locations then select, as the followng image

enter image description here

7
  • This fixes a couple items, but not all
    – Murwa
    Commented Aug 13, 2019 at 18:20
  • I had Xcode 10.3, 11.1 and 11.2 and Xcode wasn't able to figure out which version to use for the Command Line Tools and left the dropdown with empty. Once 11.1 was selected for my purpose, git commands started to work. Commented Nov 18, 2019 at 23:34
  • This popup is equivalent to calling xcode-select --switch with the path to the Xcode package of whatever version you select here, by the way.
    – uliwitness
    Commented Feb 15, 2020 at 10:55
  • Good hint thank you , Whatever the way , the important thing is to solve the issue
    – taha
    Commented Apr 6, 2020 at 13:54
  • This works for me.. Thanks a lot. I was having old and new version of Xcode at different locations.
    – iGW
    Commented Apr 13, 2020 at 10:35
52

I've used xcode-select --install given in the accepted answer in previous major releases.

I've just upgraded to OS X 10.15 Catalina and run the Software Update tool from preferences again after the OS upgrade completed. The Xcode utilities update was available there, which also sorted the issue using git which had just output xcrun: error: invalid active developer path (/Library/Developer/CommandLineTools)

1
  • If you have Xcode installed, you do not need the separate command line tools install. Just make sure you run xcode-select --switch /Applications/Xcode.app/Contents/Developer or xcode-select --reset so Terminal will use the command line tools inside Xcode instead of the ones installed by the "command line tools" standalone installer. From then on, the App Store will auto-update Xcode and your tools will stay current.
    – uliwitness
    Commented Feb 15, 2020 at 10:52
48

I figured out the Xcode Command Line Tools part from the error message, but after running Xcode and getting the prompt to install the additional tools it did claim to install them, but still I got the same error after opening a new terminal.

So I did the xcode-select --install manually and after that it worked for me.

1
  • 4
    If you have Xcode installed, you do not need the separate command line tools install. Just make sure you run xcode-select --switch /Applications/Xcode.app/Contents/Developer or xcode-select --reset so Terminal will use the command line tools inside Xcode instead of the ones installed by the "command line tools" standalone installer. From then on, the App Store will auto-update Xcode and your tools will stay current.
    – uliwitness
    Commented Feb 15, 2020 at 10:53
43

Mac OS : Big Sur

First Priority

sudo xcode-select --reset

sudo xcodebuild -license

Second Priority

xcode-select --install
9
  • 5
    Best answer for Big Sur
    – Ling Vu
    Commented Dec 7, 2020 at 12:46
  • 2
    For big Sur, this first priority is usefull. Thanks for saving lot of time and Data.
    – Manish
    Commented Dec 14, 2020 at 9:15
  • 2
    I am using Big Sur (xcode-select --install) helped me.
    – Ali Qaderi
    Commented Dec 15, 2020 at 7:00
  • Work for me on catalina Commented Mar 4, 2021 at 13:06
  • best answer! This issue doesn’t require installation of the tool again
    – MMK
    Commented Mar 31, 2021 at 16:36
35

Following worked on M1

ProductName:    macOS
ProductVersion: 11.2.1
BuildVersion:   20D74

% xcode-select --install

Agree the Terms and Conditions prompt, it will return following message on success.

% xcode-select: note: install requested for command line developer tools
33

If you have Xcode downloaded manually (i.e. not from the App Store) or don't have Xcode at all:

  1. sudo rm -rf /Library/Developer/CommandLineTools
  2. Go to https://developer.apple.com/download/more/ to download Command Line Tools (macOS 10.14) for Xcode 10
  3. Setup Command Line Tools

If you have Xcode installed from the App Store:

  1. xcode-select --install
3
  • 2
    I want to install Command Line Tools only and Not Xcode. This solution seems to be the best. Minimal install Commented Jul 18, 2019 at 17:34
  • 2
    Perfect for me since I don't need Xcode but I do need Git :) Commented Jan 22, 2020 at 12:37
  • After I installed Catalina and trying the xcode-select --install answer I had an error from the UI installer: "xcode-select: note: install requested for command line developer tools". This was the only thing that worked for me since I didn't want to install Xcode. (I used the Command Line Tools for XCode 12.) Commented Sep 27, 2020 at 21:11
30

Open Terminal:

install XCode developer tools and fix the problem.

$ xcode-select --install

Reset the path to Xcode if you have several versions:

$ xcode-select --switch /Applications/Xcode.app
$ xcode-select --switch /Library/Developer/CommandLineTools
2
  • 2
    If you have Xcode installed, you do not need the separate command line tools install. Just make sure you run xcode-select --switch /Applications/Xcode.app/Contents/Developer or xcode-select --reset so Terminal will use the command line tools inside Xcode instead of the ones installed by the "command line tools" standalone installer. From then on, the App Store will auto-update Xcode and your tools will stay current.
    – uliwitness
    Commented Feb 15, 2020 at 10:56
  • 2
    Also, it makes no sense to do both calls to xcode-select --switch above. The second one overwrites what the first one did. Do the first one and your command line tools will update as part of Xcode.
    – uliwitness
    Commented Feb 15, 2020 at 10:57
27
  1. Run this command:

xcode-select --install

  1. Hit return for a progress indicator on the Command Line Tools download.

  2. After installation of the Command Line Tools has been completed, your Mac should be rebooted. If you’re getting “xcrun error invalid active developer path” while working in Terminal, refresh the application or relaunch it.

Even after following the above-mentioned steps, if you see the error: invalid active developer path (/Library/Developer/CommandLineTools). The next step would be to try and install Command Line Tools using a DMG file that can be downloaded directly from the Apple website.

Again, if you are using Homebrew, you need to update it. You don’t need to uninstall and again install Homebrew on Mac.

NOTE: If you are using Homebrew, try updating it after re-installing Command Line tools.

Credits: Git not working after macOS Update

14

This just happened to me after upgrading my MacBook Pro to macOS v13 (Ventura). After the upgrade, the Git command line stopped working with showing up this message.

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

Running brew upgrade fixed the Git command line.

2
  • 3
    Thank you, it worked. I've deleted Xcode before because I don't need it anymore. Commented Nov 3, 2022 at 15:59
  • 2
    I've got an error: Error: No developer tools installed Commented Nov 3, 2022 at 18:40
12

As of September 13, 2022, I had a similar issue after upgrading my MacBook Pro M1 to macOS v12.6 (Monterey), and although I followed some of the answers, my Mac kept prompting me with a dialogue to install Git as a developer tool. Every time that the installation was completed, I was prompted to the same dialogue.

Finally, I had to do a combination of all the answers to make it work:

  1. First remove the command line tool:

    sudo rm -rf /Library/Developer/CommandLineTools
    
  2. Reinstall the xcode-select:

    xcode-select --install
    

The above will prompt you with a dialogue to confirm the installation.

  1. Set path to the Xcode folder with following:

    sudo xcode-select -switch /Library/Developer/CommandLineTools
    
0
10

For me, I didn't have xcode installed (on Mojave OS). I went to the App Store on my mac and downloaded it, then went back to terminal and typed git and hit enter, then it worked.

10

I observed in the Catalina privacy setting if Xcode not added in Full access disk I will get the same error, Xcode does not run scripts. Add your Xcode the same as in the attached image. After that clean build and run. Hope so it will work. Security & Privacy

0
9

I found that my version of Xcode was too outdated and installing command-line-tools wasn't helping. Here's what I did:

  • I completely uninstalled the outdated XCode
  • I reinstalled the most recent XCode from the app store
  • That was all. Git was restored.
0
9

For me, for the macOS v13 (Ventura) user, installing this software helped:

Enter image description here

I wasn't able to run any Xcode install commands, and Git was not working at all.

You can find this package here https://developer.apple.com/download/all/

1
  • 1
    This also worked for me by installing Xcode through the App Store.
    – Boaz
    Commented Nov 30, 2022 at 9:01
8

This works for me

sudo xcode-select --reset 
sudo xcodebuild -license

X-code must be installed.

6

For those using Catalina and Xcode-beta:

sudo xcode-select -s /Applications/Xcode-beta.app/Contents/Developer
5

I updated my macOS yesterday,from macOS Mojave(10.14.6)to macOS Catalina(10.15.7),I was executing "git" command in my project. I get same errors。

run:

xcode-select --install
1
  • 4
    Please don't repeat existing answers Commented Aug 28, 2021 at 12:39
5

After Updating macOS to Monterey (12.3) from BigSur getting such issue

only worked-

xcode-select --install

Done!

1
  • 1
    That is the same with the accepted answer, but with less information!
    – alianos-
    Commented Apr 28, 2022 at 8:41
5

With previous app development experience, may I say with confidence that the Git version delivered with Apple always create problems. So the sooner you get rid of Apple Git the better, so may I suggest:

brew uninstall git
brew update
brew install git

# which git
/usr/local/bin/git
1
  • I think you might have the right idea bud. I ran into issues twice. Idk why I need a full development suite just to have git.
    – dustbuster
    Commented Sep 15, 2022 at 0:04
4

For me It happened after Mac OS update to Mojave and git was not functioning in Intellij

Solution:- Go to Settings, then File | Settings | Version Control | Git and edit Path to Git executable field which is /usr/local/bin/git

4

I had the same issue and couldn't use SVN after the update,

Just in case if doing xcode-select --install didn't fix the issue,

You might see,

svn: error: The subversion command line tools are no longer provided by Xcode.

Refer : https://developer.apple.com/documentation/macos_release_notes/macos_catalina_10_15_release_notes

Try installing the svn by brew

brew install svn

This should get you going.

1
  • I have been thinking that brew is perhaps a better source for git! So much overhead using apple developer.
    – dustbuster
    Commented Dec 5, 2022 at 15:24
3

MacOS :Monterey
Year: 2022

Solution: Upgrade to 12.2.1 or later

I upgraded to Monetery 12.2 as my Macbook pro got replaced. Ran into same issue as OP:

Git is not working after macOS Update (Xcrun: error: invalid active developer path (/Library/Developer/CommandLineTools)

One would think that by this time Apple would have added xCode & developer tools into OS main build. Turned out they did. I had to upgrade to 12.2.1, which included "command line tools for xCode".
I still need to do step upgrade to 12.4 , but I believe we finally have these tools as part of OS build.

Here's screen-shot while attempting to upgrade from 12.2.1 to 12.3.1 (I forgot to take one while upgrading from 12.2 to 12.2.1, but I am pretty sure it had same Addons)

enter image description here

Not the answer you're looking for? Browse other questions tagged or ask your own question.