23

I have updated Xcode version to 7.3.1.when I use 'git status',I find an error! as follow:

$git status
sh: line 1:  1601 Segmentation fault: 11  /Applications/Xcode.app/Contents/Developer/usr/bin/xcodebuild -sdk / -find git 2> /dev/null
git: error: unable to find utility "git", not a developer tool or in PATH

Thank you advanced!

1
  • My Mac Opeation System version is OS X 10.11.5 Commented Jun 6, 2016 at 2:48

6 Answers 6

97

This happened to me also with upgrading to High Sierra and XCode to 9. This sequence has fixed it.

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

Found this answer on https://davidwalsh.name/fix-git-high-sierra-upgrade (article and comments.)

Sign up to request clarification or add additional context in comments.

1 Comment

This is the best answer because it requires no reboot or restart :) Through many cycles of sleep/wake terminal can lose reference to command line tools. If you already have xcode-select installed (as many do) just running the second line fixes this.
57

I had this same problem -- I exited my bash session (closed the terminal) and started a new one and it fixed it.

3 Comments

THX...it's a weird problem
Same here, it would be the right answer, just the terminal lost the session.
This was useful for MacOS 10.13 and Xcode 9.3 (after reinstalling commandline tools)
6

The best solution will be to download and install it - even that you assume it is already installed: https://git-scm.com/download/mac

4 Comments

Thank you very much for your help! I have solved this problem in the way that you provided!
If you have Homebrew installed, you can install Git via the brew install git command. See here: git-scm.com/book/en/v1/Getting-Started-Installing-Git
This is a workaround that doesn't fix the underlying problem -- that xcode for some reason fails to launch developer tools. It should not be the accepted answer. You will just run into the same problem with other developer tools.
well, at the time of the question (more than 3 years ago), it solved the problem for him so he accepted the answer.
2

I had the same issue after upgrading to Big Sur. I fixed this issue by running the following command:

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

P.S. I did not need to run this command: xcode-select --install

Comments

0

For me, I had to uninstall and reinstall all my brew applications, as documented here.

i.e.

brew list -1 > brew.txt # list out all installed packages
brew list -1 | xargs brew rm --force # remove all installed packages
brew install $(cat brew.txt | tr '\n' ' ') # install all previously installed packages

Comments

0

None of the above solutions fixed the issue for me, I had to actually just restart my computer which fixed it. This was a weird bug.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.