My computer can't find the git command

5,816

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"
Share:
5,816

Related videos on Youtube

Jesse Green
Author by

Jesse Green

Updated on September 18, 2022

Comments

  • Jesse Green
    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 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.

    • kenorb
      kenorb about 9 years
      What's your sudo xcode-select -p path?
    • kenorb
      kenorb about 9 years
      Does agreeing to licence helps? sudo xcodebuild -license
  • Jesse Green
    Jesse Green about 9 years
    All of those tests are what you said they should be. Except I'm not sure what you mean by rc files
  • kenorb
    kenorb about 9 years
    On 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
    Jesse Green about 9 years
    it's empty unfortunately
  • kenorb
    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, add export PATH="/usr/local/git/bin:$PATH"
  • Jesse Green
    Jesse Green about 9 years
    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