2
votes

I have been trying to instal the Git on my mac, But every time I use the command $git --version.

I get the following error

xcrun: error: active developer path ("/Volumes/Xcode/Xcode.app/Contents/Developer") does not exist, use xcode-select --switch path/to/Xcode.app to specify the Xcode that you wish to use for command line developer tools (or see man xcode-select)

I have already installed the Xcode on my mac for iOS App development. I am not sure what this error is trying to say.

6
Are the XCode command line tools installed (developer.apple.com/downloads)? Please describe how you installed Git. I have switched to HomeBrew as a package manager and have been really happy with it. If you want to try it out, I have some instructions here: steve-tarver-mac.blogspot.com/2015/05/install-homebrew.html.Steve Tarver
So did you do what that message said and run xcode-select --switch path/to/Xcode.app? And if so, what happened? You should describe that in your question.sideshowbarker
@sideshowbarker I tried, but it says sudo: xcode-select: command not foundJasmeet
@starver I just installed the git from git-scm.com/download/macJasmeet
So if you do ls /usr/bin/xcode* it shows nothing, right? If so then you must not have XCode installed correctly, and you need to try re-installing it—from the App Store, or starting at itunes.apple.com/jp/app/xcode/id497799835sideshowbarker

6 Answers

9
votes

So from discussion in the comments above, it seems the right fix here is just to run the command /usr/bin/xcode-select -switch once (i.e., run it with the full path to the executable, rather than just as xcode-select) with /Applications/Xcode.app/Contents/Developer/ as the argument:

sudo /usr/bin/xcode-select -switch /Applications/Xcode.app/Contents/Developer

After running that once, everything should work as expected from then on.

8
votes

My case:

I removed XCode. JetBrains integration with git - breaks. Found this error in terminal.

My soltuion:

I don't want to download XCode to restore PyCharm. So I ran:

sudo xcode-select --reset
3
votes
sudo /usr/bin/xcode-select --switch /Library/Developer/CommandLineTools

and reboot your computer.

1
votes

You can install git via the brew package manager for Mac. I recommend installing software this way since it's a great way to manage your installed packages in one place. For example, you can do brew update to get a list of the latest package updates, or brew upgrade to upgrade all of your software installed through brew.

  1. To install brew, open a terminal window and run:

    ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
    
  2. Update your brew packages with brew update

  3. Install git with brew install git
1
votes

I had installed git, then returned to a terminal window open prior to the installation. I try running command git --version and this raised error message below. To resolve, I ran command source /etc/profile in same terminal window. BTW, terminal window is inside my Webstorm and my end goal is to git init and setup git for my new reactjs project. Happy coding!

The error:

xcrun: error: active developer path ("/Volumes/Xcode/Xcode.app/Contents/Developer") does not exist, use \`xcode-select --switch path/to/Xcode.app\` to specify the Xcode that you wish to use for command line developer tools (or see \`man xcode-select\`)
1
votes

It was easier for me to let Xcode pick the install location of Command Line Tools for me, instead of the other way around. After downloading the .xip file from the Apple Developer downloads page, expanding the compressed contents, and installing Xcode.App, I was able to open it using Spotlight.

xcode in spotlight

And open preferences:

enter image description here

And select my Command Line Tools under "Locations".

enter image description here