90

After upgrading to OSX 10.10 Yosemite Beta, running git pull is returning the following error:

/Library/Developer/CommandLineTools/usr/libexec/git-core/git-pull: line 11: git-sh-setup: No such file or directory

I've checked the referenced git-core directory and the git-sh-setup.sh is there.

Other git commands are working exactly as expected

3
  • 3
    I'm having this issue as well, except with git stash. I'll let you know if I find a solution
    – cadlac
    Commented Jun 3, 2014 at 19:28
  • Was only having this issue with zsh...git seemed to work fine when run from bash. Zsh related? Commented Jun 4, 2014 at 22:03
  • 12
    This was a bug in iTerm2 with zsh. iTerm2 fixed it in its latest release (v1.0.0.20140629)
    – rds
    Commented Aug 12, 2014 at 22:55

10 Answers 10

100

I think the cleanest solution for this for now is to change the initial command in your iTerm session to be

/usr/bin/login -f <your user name>

This fixes the issue for me.

A further data point for analysis of the issue: It seems that in 10.10, multiple copies of the PATH environment variable exist and subshells seem to prefer the second copy.

You can reproduce this by launching any cocoa application on the console as launched by iTerm. You'll get a warning that looks like this:

2014-06-04 19:23:09.859 gitx[14676:362580] *** -[NSProcessInfo environment]: Warning: duplicate definition for key 'PATH' found in environment -- subsequent definitions are ignored.  The first definition was '(the path I have configured in my shell)', the ignored definition is '/usr/bin:/bin:/usr/sbin:/sbin'.

I believe this to be a problem in 10.10 and not iTerm, but something iTerm is doing is causing it to manifest itself (this doesn't happen in Terminal.app)

Update: This is caused by iTerm doing "interesting" stuff to the environment. Update to the official release of iTerm 2.0 to make this problem go away.

13
  • 6
    This should be the correct answer, amazing fix. However, I set the command to /usr/bin/login -f $USER, just so I can have the same profile on multiple accounts :)
    – cadlac
    Commented Jun 5, 2014 at 6:48
  • 12
    Apparently, bash removes all duplicated environment variables. So, if you set the command to /bin/bash -c /bin/zsh it will preserve other environment variables, e.g. $SSH_AUTH_SOCK.
    – cypheon
    Commented Jun 5, 2014 at 8:54
  • 2
    This fixed the issue for me in the cleanest way so far. Thanks a lot!
    – meghaphone
    Commented Jun 6, 2014 at 21:20
  • 2
    This fixs git. But whenever I need to use ssh with my id_rsa.pub, I was asked to enter the passphrase. I didn't have to do this before change initial command, nor in Terminal.app. Any idea?
    – ZeR0
    Commented Jun 7, 2014 at 16:40
  • 5
    I think /bin/bash -c /bin/zsh is better than /usr/bin/login -f <your user name>, because it keeps the character encoding. /usr/bin/login -f <your user name> lost my encoding and I cannot display my files as normal.
    – Alpha Liu
    Commented Jun 10, 2014 at 15:10
35

I believe this is a bug in iTerm when using zsh. They deliberately don't invoke /usr/bin/login, and they don't use execle to clear the environment variables like they should be.

8
  • 1
    Wow I think you're right. I have spent hours trying to get various Git fixes to work, and it turns out switching from iTerm2 w/ zsh to Yosemite's default Terminal (still with zsh) works great. How did you find this?
    – jbnunn
    Commented Jun 5, 2014 at 0:59
  • 8
    Well, this is the most specific group of people ever... What an edge case.
    – Drew
    Commented Jun 5, 2014 at 2:35
  • 2
    that was a very good analysis. So a good workaround is to set the initial command in iTerm to /usr/bin/login -f <your user name>.
    – pilif
    Commented Jun 5, 2014 at 4:10
  • 13
    Another workaround is setting the login shell command in iTerm to /bin/bash -c /bin/zsh
    – Vince
    Commented Jun 5, 2014 at 14:05
  • 1
    Changing from login shell to command in the Preferences > Profile > General section, and using /bin/bash -c /bin/zah as @Sorenly has suggested, fixed this right up!
    – jlmakes
    Commented Oct 18, 2014 at 10:12
20

Downloading the newest version of iTerm2 fixed this for me!

3
  • 1
    If you want to solve it without proving that you are a techie..., just do this. Thanks to Marthyn... Commented Oct 22, 2014 at 4:19
  • As the comments below said, it appears to be iTerm and zsh together that prevents git pulls from working. Going to iTerm2 fixes it.
    – MikeHoss
    Commented Nov 12, 2014 at 16:15
  • 4
    To clarify @MikeHoss, iTerm2 version 1.0.x doesn't work, but iTerm2 version 2.0.x does. Both are iTerm2, but the version is what matters. Commented Nov 19, 2014 at 23:07
16

Another solution, modify your iTerm2

cd /Applications/iTerm.app/Contents/MacOS
mv iTerm iTerm-bin

cat > iTerm <<EOF
#!/bin/sh
unset PATH
\${0}-bin
EOF

chmod +x iTerm

Done.

Enjoy your iTerm2 with Yosemite!

2
  • iTerm2 is the problem and this is among the best solutions to the problem. Kudos.
    – ocodo
    Commented Jun 19, 2014 at 1:39
  • I was experiencing this problem even on the public 10.10 release, and this fixed it. Thanks Feng!
    – Ash Furrow
    Commented Oct 18, 2014 at 5:37
13

As a temp solution I modified git-pull lines 11, 12, and 336 to be:

. /usr/local/Cellar/git/2.0.0/libexec/git-core/git-sh-setup

. /usr/local/Cellar/git/2.0.0/libexec/git-core/git-sh-i18n

eval="/usr/local/Cellar/git/2.0.0/libexec/git-core/git-merge $diffstat $no_commit $verify_signatures $edit $squash $no_ff $ff_only"

This fixes git-pull for now, but I'm sure there is a better solution.

4
  • 2
    I also had to change like 231 to . /usr/local/Cellar/git/2.0.0/libexec/git-core/git-parse-remote Commented Jun 3, 2014 at 20:51
  • 2
    In case I needed to change this, I set up mine to point to $GIT_PATH/git-sh-setup, etc.
    – TheJF
    Commented Jun 3, 2014 at 21:05
  • 1
    I'm getting /usr/local/Cellar/git/2.0.0/libexec/git-core/git-sh-setup: line 334: git: command not found fatal: 'pull' appears to be a git command, but we were not able to execute it. Maybe git-pull is broken? After applying this fix, anyone have an idea what to do?
    – Drew
    Commented Jun 4, 2014 at 4:08
  • @Andrew This is ugly but I had to go through git-sh-setup and replace all git with /usr/local/bin/git. There were a few instances of git in git-pull also that had to be replaced
    – jbnunn
    Commented Jun 4, 2014 at 17:37
3

Here's a temporary fix (assuming Homebrew and Git 2.0.0) if you need Git to work before an official fix comes out. I setup two shell variables:

export GIT_PATH="/usr/local/Cellar/git/2.0.0/bin"
export GIT_CORE_PATH="/usr/local/Cellar/git/2.0.0/libexec/git-core"

... and then replaced instances of git with appropriate absolute links. You can use the following Gists to do the same:

  • Replace /usr/local/Cellar/git/2.0.0/libexec/git-core/git-sh-setup/ with git-sh-setup
  • Replace /usr/local/Cellar/git/2.0.0/libexec/git-core/git-stash/ with git-stash
  • Replace /usr/local/Cellar/git/2.0.0/libexec/git-core/git-pull/ with git-pull

This is a hack for sure, but it will get you going.

EDIT: Make sure you look at the answer from @pilif before doing this...

1

Ubiquill's workaround applies for git rebase (and presumably whichever other functions don't work) as well. In that case, it requires replacing lines 47 and 48 with the following *:

. /usr/local/Cellar/git/2.0.0/libexec/git-core/git-sh-setup
. /usr/local/Cellar/git/2.0.0/libexec/git-core/git-sh-i18n

* This path assumes that you have git installed with homebrew, and it lives inside of /usr/local/Cellar/git/2.0.0/.

1

Edit your git-pull file and add this line on top of it (just after the comment block)

PATH="$(dirname $0):$PATH"

Or just copy paste this in your terminal :

ed -s $(which git-pull) <<< $'6i\nPATH="$(dirname $0):$PATH"\n.\nwq'

Update: As presumed by pilif, since last iTerm2 update (1.0.0.20140629), git-pull run properly without this PATH override.

1
  • This seems to be the only solution to go one step forward in my configuration. After adding the PATH line, I get this error when I try to PULL: git: 'credential-osxkeychain' is not a git command. See 'git --help'. Any ideas?
    – kiks73
    Commented Nov 5, 2014 at 15:15
1

There is an update to git-rebase.sh

https://github.com/git/git/pull/110/files

0

UPDATE: still not working with release mentioned below, my mistake. Git push works Git pull doesn't.

It seems to me that the issue has been fixed by Apple with Mac OS X Yosemite 10.10 (14A329r). i am on the general Beta Yosemite channel (not developer). Git push/pull works as expected again without any modifications.

2
  • No, I'm experiencing duplicated environment variables on 14A329r, so it has not been fixed on that build.
    – Zr40
    Commented Sep 8, 2014 at 9:03
  • @Zr40 thx. you are right. somehow Git push works now? for me but Git pull is still NOT working. Commented Sep 8, 2014 at 10:31

Not the answer you're looking for? Browse other questions tagged or ask your own question.