269

After upgrading to MacOS X 10.15 Catalina, I cannot run any git commands in my shell:

The default interactive shell is now zsh.

To update your account to use zsh, please run chsh -s /bin/zsh.

For more details, please visit https://support.apple.com/kb/HT208050.

~ | git

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

I thought there's a problem with my shell, so I followed the instructions to change the default Mac OS shell back to bash, using the GUI and also using the command line:

chsh -s /bin/bash

I also restarted the computer. However, I still see the same message, even though echo "$SHELL" outputs /bin/bash.

Community
  • 1
  • 1
  • What has the shell got to do with anything? This looks like an issue with the Xcode command line tools. – trojanfoe Oct 08 '19 at 06:16
  • 2
    Answered at https://apple.stackexchange.com/questions/254380/why-am-i-getting-an-invalid-active-developer-path-when-attempting-to-use-git-a/254381#254381 – The Onin Oct 08 '19 at 17:41

1 Answers1

461

You'll need to reinstall the command line tools:

$ xcode-select --install
naydichev
  • 4,672
  • 1
  • 19
  • 14
  • 24
    It worked! Also add `export BASH_SILENCE_DEPRECATION_WARNING=1` to your `~/.bash_profile` file to get rid of the annoying message. –  Oct 08 '19 at 06:42
  • 21
    Learn this command by heart. It is almost always the answer to development issues after upgrading macOS. – idmean Oct 08 '19 at 17:03
  • 42
    `xcode-select --reset` was the solution for my device. – Mendel Oct 10 '19 at 15:36
  • 8
    sudo xcode-select --reset worked. However it additionally required to agree to terms and conditions. The command was: sudo xcodebuild -license – David Hladky Oct 11 '19 at 08:47
  • 1
    It may be possible to dodge the license agreement by running `xcodebuild -runFirstLaunch` instead of the provided command. – vhs Oct 16 '19 at 13:40
  • You can also run `sudo xcodebuild -license accept` to accept it without a prompt. – ryanpcmcquen Nov 02 '19 at 20:03
  • if it writes `xcode-select command not found` or something like that, just reboot after the OS upgrade and try run the `xcode-select --install` again. – The Vojtisek Jan 02 '20 at 13:22
  • `sudo xcode-select --reset` worked for me without any hassle. – Abhishek Aggarwal May 31 '20 at 11:55
  • `sudo xcode-select --reset` worked for me. – Vikram K Jun 07 '20 at 16:35
  • 1
    The install command said "Can't install the software because it is not currently available from the Software Update server". Any idea how to get pass this? – Guna Sep 30 '20 at 11:58
  • 1
    @Guna I manually downloaded and installed the CMD line tools from: https://developer.apple.com/download/more/?=command%20line%20tools I used the Xcode 12 version. – Dragos Stanciu Sep 30 '20 at 12:48
  • 1
    sudo xcode-select --reset works for me. – JunaidFarooqui Oct 12 '20 at 21:46
  • PYCHARM: It did not work for me. Terminal spewed out this message to me: "xcode-select: error: command line tools are already installed, use "Software Update" in System Settings to install updates". I then went to: (Pycharm) Preferences -> Version Control -> Git. And there I set Path to Git executable to /usr/bin/git ----- *NOTE: I have just today updated my macOS M1 2020 to VENTURA OSX 13.0* – victorkolis Oct 25 '22 at 04:18