Open xPaw opened 9 years ago
This looks really weird, thanks for reporting. It looks like /home/gfreeman/SteamLinux/.git
is a valid git repository. I can't imagine what would trip up hub. Can you try running different hub commands manually like hub ci-status
or hub browse
and see if they suffer from the same error?
/home/gfreeman/SteamLinux/.git
is indeed a valid repository.
I've tried to run the exact same script with same arguments under the same user manually, and it worked. For some reason when PHP executes it, hub
command fails, despite being in the correct folder.
Must be something about the environment which PHP initializes for its sub-processes, but I can't guess without access to your machine. Can you inspect environment variables via env
, particulary ones whose name mentions "GIT"?
The only variables when PHP runs env
are USER, HOME and PWD.
I have no idea why it doesn't work within PHP. Basically, hub internally calls git rev-parse -q --git-dir
to check if the current directory is in a git repo.
As you can see in the script output, git rev-parse -q --git-dir
actually finds the .git
repository, and the git commit/push commands do work, it's the hub
that fails.
@xPaw It's been a long time since you reported this issue, and I have received no similar reports. Did this remain a problem for you? Do you think we can shrug this off and close this? I'm sorry I couldn't help. Thanks
Well, that's fun. I moved to a completely new server (with new OS installation), and I can still reproduce this issue.
git version 2.1.4
hub version 2.3.0-pre8
EDIT: Doing hub status
prints exec: "git": command not found
. Adding export PATH=/usr/bin
before running hub
fixes it.
So this leads to two points:
git
works, but hub
executing git
does not?hub
needs to correctly displays when git
is not found. This works for aliased git commands, but not for commands hub
implements.I'm sorry this is still giving you problems.
1. Why
git
works, buthub
executinggit
does not?
I would guess that this happened because the PATH for the hub process didn't have /usr/bin
before you manually added it. It is the responsibility of the parent process to ensure that PATH is well formed. I think your workaround is fine and that this is not indicative of a bug in hub.
2.
hub
needs to correctly displays whengit
is not found. This works for aliased git commands, but not for commandshub
implements.
Can you explain more about this? Which is the command that you run with hub that has a non-friendly error message, what does that message say, and what should it say instead?
Can you explain more about this? Which is the command that you run with hub that has a non-friendly error message, what does that message say, and what should it say instead?
I would expect a message like hub status
gave me: "git": command not found
instead of saying fatal: Not a git repository
. The command that produces this message is hub pull-request
.
@xPaw Thanks; I'll see what I can do about improving this error message.
Same use case and same error calling this within php. His solution of including export PATH=/usr/bin before hub pull-request also solved this for me. I can confirm that this remains a bug, albeit very low priority given the easy workaround.
Thanks for this incredible library!
My script looks like this:
And the output of that is:
Version:
Script itself is outside of the git directory, so that could be cause it to use wrong directory?