error: unable to find utility "git", not a developer tool or in PATH
Asked Answered
K

6

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!

Kislev answered 6/6, 2016 at 2:45 Comment(1)
My Mac Opeation System version is OS X 10.11.5Kislev
S
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

Selfhypnosis answered 6/6, 2016 at 4:43 Comment(4)
Thank you very much for your help! I have solved this problem in the way that you provided!Kislev
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-GitSlipway
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.Jos
well, at the time of the question (more than 3 years ago), it solved the problem for him so he accepted the answer.Selfhypnosis
G
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.)

Gastroenteritis answered 12/2, 2018 at 1:49 Comment(2)
Thanks this is amazing! :)Nervous
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.Morril
O
57

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

Overbalance answered 9/9, 2017 at 21:17 Comment(3)
THX...it's a weird problemMesmerism
Same here, it would be the right answer, just the terminal lost the session.Apportion
This was useful for MacOS 10.13 and Xcode 9.3 (after reinstalling commandline tools)Hasbeen
S
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

Selfhypnosis answered 6/6, 2016 at 4:43 Comment(4)
Thank you very much for your help! I have solved this problem in the way that you provided!Kislev
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-GitSlipway
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.Jos
well, at the time of the question (more than 3 years ago), it solved the problem for him so he accepted the answer.Selfhypnosis
W
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

Warden answered 13/9, 2021 at 3:24 Comment(0)
A
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
Au answered 27/3, 2019 at 3:54 Comment(0)
A
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.

Agentive answered 2/11, 2019 at 22:54 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.