6

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.

17
  • 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. Commented Sep 19, 2015 at 23:15
  • 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. Commented Sep 19, 2015 at 23:17
  • @sideshowbarker I tried, but it says sudo: xcode-select: command not found Commented Sep 19, 2015 at 23:24
  • @starver I just installed the git from git-scm.com/download/mac Commented Sep 19, 2015 at 23:25
  • 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/id497799835 Commented Sep 19, 2015 at 23:29

7 Answers 7

24

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
Sign up to request clarification or add additional context in comments.

Comments

13

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.

2 Comments

I did this also i checked my xcode path by xcode-select -print-path and gave me /Applications/Xcode.app/Contents/Developer. But when I ran you solution command it shows xcode-select: error: invalid developer directory '/Applications/Xcode.app/Contents/Developer'
I get the same result as @NoobCoder. Does anyone have an update?
10
sudo /usr/bin/xcode-select --switch /Library/Developer/CommandLineTools

and reboot your computer.

1 Comment

If you, like me, deleted the application Xcode and still wants to use the command line tools – this is the solution that works! Thx!
5

Try this below answer. It's worked for me.

Open your Xcode Preferences,

--> Select Locations

--> Select your specific Xcode version in Command Line Tools

enter image description here

Comments

2

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

Comments

1

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

Comments

1

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\`)

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.