My computer can't find the git command

4

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 my PATH so I added it in. I checked and my PATH has it. My PATH 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.

Jesse Green

Posted 2015-04-23T18:24:51.333

Reputation: 143

consider adding or symlinking to default bin (aka /usr/bin) that is using the version for android-sdk which presumably is not default called by OSX – linuxdev2013 – 2015-04-23T18:30:05.527

That's interesting, there's already a git file in /usr/bin – Jesse Green – 2015-04-23T18:33:36.667

What's your sudo xcode-select -p path? – kenorb – 2015-04-23T18:44:15.390

Does agreeing to licence helps? sudo xcodebuild -license – kenorb – 2015-04-23T18:47:44.257

Answers

4

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"

kenorb

Posted 2015-04-23T18:24:51.333

Reputation: 16 795

1All of those tests are what you said they should be. Except I'm not sure what you mean by rc files – Jesse Green – 2015-04-23T18:55:28.190

On terminal, type: echo $DYLD_LIBRARY_PATH and see if you've any value. If it's empty, then it's fine as well. – kenorb – 2015-04-23T18:56:31.313

it's empty unfortunately – Jesse Green – 2015-04-23T18:58:29.650

@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, add export PATH="/usr/local/git/bin:$PATH" – kenorb – 2015-04-23T19:01:52.780

moving /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 – Jesse Green – 2015-04-23T19:11:36.090