My computer can't find the git command
You should make sure that you're working on the right XCode environment, for example:
sudo xcode-select --switch /Applications/Xcode.app/Contents/Developer
Check the current value by: sudo xcode-select -p
.
Then make sure you've accepted the license by running:
sudo xcodebuild -license
and by typing agree
and check if that works.
Double check if you're not overriding DYLD_LIBRARY_PATH
system variable by unsetting it from your rc files. Test in Terminal by echo $DYLD_LIBRARY_PATH
.
If none of above works, you've to change the order of your PATH
by editing it in ~/.bashrc
or ~/.bash_profile
or by adding the following line:
export PATH="/usr/local/git/bin:$PATH"
Related videos on Youtube
Jesse Green
Updated on September 18, 2022Comments
-
Jesse Green over 1 year
I recently installed git on my computer (OSX 10.10.1) and when I run git I get
git: error: unable to find utility "git", not a developer tool or in PATH
. So I checked, found that I didn't have the directory that git was in in myPATH
so I added it in. I checked and myPATH
has it. MyPATH
is/Library/Frameworks/Python.framework/Versions/3.4/bin:/Library/Frameworks/Python.framework/Versions/3.4/bin:/Library/Frameworks/Python.framework/Versions/3.4/bin:/Library/Frameworks/Python.framework/Versions/3.4/bin:/Users/Jesse/SDKs/android-sdk-macosx/platform-tools:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/Users/Jesse/SDKs/android-sdk-macosx/tools/android:/opt/X11/bin:/usr/local/git/bin
You'll notice that the last one is
/usr/local/git/bin
. If I cd to /usr/local/git/bin and run./git
then git runs just fine. I can't figure out what might be causing this. I tried restarting my computer too just in case without any change.-
kenorb about 9 yearsWhat's your
sudo xcode-select -p
path? -
kenorb about 9 yearsDoes agreeing to licence helps?
sudo xcodebuild -license
-
-
Jesse Green about 9 yearsAll of those tests are what you said they should be. Except I'm not sure what you mean by rc files
-
kenorb about 9 yearsOn terminal, type:
echo $DYLD_LIBRARY_PATH
and see if you've any value. If it's empty, then it's fine as well. -
Jesse Green about 9 yearsit's empty unfortunately
-
kenorb about 9 years@JesseGreen Then as workaround move your
/usr/local/git/bin
before/usr/bin/
in your PATH in your~/.bashrc
or~/.bash_profile
. If you don't have it, addexport PATH="/usr/local/git/bin:$PATH"
-
Jesse Green about 9 yearsmoving
/usr/local/git/bin
to the beginning of my PATH seems to have solved the problem although I'm still very confused why it doesn't want to work normally but at least it's working now