Page MenuHomePhabricator

Why do phabricator hosted git repositories appear to error with 'failed to push some refs' without any error detail, even though the push works?
OpenPublic

Asked by Fordy on Jul 30 2016, 2:53 PM.

Details

Why do phabricator hosted git repositories appear to error with 'failed to push some refs' without any error detail, even though the push works?

I've tried this with a new git repository, latest version of phabricator. I can git clone the repository ok, but when I attempt to git push origin master, i get the error.

I've scoured the internet and there are many answers to this particular error, but all assume someone else committed first. This is not true here, and even if it was - my pushes aren't being rejected by remote. If I change something, the pushes do go up fine, but then I get the error:

-bash-4.3$ git push origin master:master
error: failed to push some refs to 'ssh://vcs-user@phabricator:2222/diffusion/13'

Verbose version:

-bash-4.3$ git push -v origin master:master
Pushing to ssh://vcs-user@phabricator:2222/diffusion/13
To ssh://vcs-user@phabricator:2222/diffusion/13
 = [up to date]      master -> master
updating local tracking ref 'refs/remotes/origin/master'
error: failed to push some refs to 'ssh://vcs-user@phabricator:2222/diffusion/13'

If I create a new file in the repo, the push works fine (not a fast-forward error) but then I still get the error:

-bash-4.3$ echo data-in-test-file > testfile3
-bash-4.3$ git add testfile3
-bash-4.3$ git commit -m "test file comment" testfile3
[master 9ac6b75] test file comment
 1 file changed, 1 insertion(+)
 create mode 100644 testfile3
-bash-4.3$ git push origin master:master
Counting objects: 3, done.
Delta compression using up to 8 threads.
Compressing objects: 100% (2/2), done.
Writing objects: 100% (3/3), 294 bytes | 0 bytes/s, done.
Total 3 (delta 0), reused 0 (delta 0)
To ssh://vcs-user@phabricator:2222/diffusion/13
 0f6f149..9ac6b75  master -> master
error: failed to push some refs to 'ssh://vcs-user@phabricator:2222/diffusion/13'

-bash-4.3$ git push origin master:master
error: failed to push some refs to 'ssh://vcs-user@phabricator:2222/diffusion/13'

What gives, what is stuck and causing this error? The process appears to be working fine other than this error.

If I check this repository out locally (not via vcs-user and the phabricator wrapper) push works fine.

Answers

Fordy
Updated 2,817 Days Ago

Ah ha, after much debugging, I finally found and answer to this!

For those that are intrigued:

I freshly installed phabricator on a new machine elsewhere which didn't have the problem. Then managed to replicate the problem there by breaking random things. Specifically phabricator/bin/ssh-exec - I changed the exit line to be exit(3) and this caused the problem... So it was that exiting with an error code that was causing me trouble!

I stored the error code and found it was 140 - then found this error with sudo.

-bash-4.3$ sudo -E -n -u phd /usr/bin/git-receive-pack
Bad System Call
-bash-4.3$ echo $?
140

No idea why sudo does this on this system yet, however I've worked around by avoiding using sudo for now until I can resolve:

phabricator/src/infrastructure/daemon/PhabricatorDaemon.php

Within sudoCommandAsDaemonUser()

+       $processUser = posix_getpwuid(posix_geteuid())['name'];
+
+       // sudo user is same as the current user, just run the command.
+       if ( $user == $processUser )
+               return $command;
+

Ta da! It now works and git doesn't look ill. Ta for your help chaps!

New Answer