Question

The scenario

  • I have access to this old linux server, that no longer receives any type of updates. Only break and fix. There's no git installed on the server so I installed it locally on my user at ~/opt/bin. I added the directory to my path and for development on the server I can do pretty much everything I need to do with git.
  • I decided it would be cool to do my development on my workstation instead, and push to production code that is ready.
  • I set up a bare repository at my server, created a post-receive file with a checkout -f to my GIT_WORK_TREE and seems like everything is setup accordingly.

The problem

When I try to push my master branch, I get the following error:

 sh: git-receive-pack: command not found
 fatal: The remote end hung up unexpectedly

I know why this is happening. The $PATH on my SSH is only seeing /usr/bin:/bin:/usr/sbin:/sbin

My user is setup with a /bin/sh shell so using .profile/.bashrc/.bashprofile is not an option.

I can't use .ssh/environment either, because my PermitUserEnvironment is set to no.

I tried to create a hooks/pre-receive and set the path there, that did not work either.

Any idea on how to make SSH see git and get this working?

Thanks

Was it helpful?

Solution

I found it!

http://www.wiredrevolution.com/git/fix-git-upload-pack-and-git-receive-pack-errors-on-shared-hosting

The second solution involves adding the path to your git-upload-path and git-recieve-path in your local .git/config file under [remote "origin"]. This is the easiest method as you only have to make this change once.

[remote "origin"]
url = <repo address>
fetch = +refs/heads/*:refs/remotes/origin/*
uploadpack = <path to git-upload-pack>
receivepack = <path to git-receive-pack>

OTHER TIPS

That is the problem using the default ssh daemon: it forces the PATH to a immutable value, and if your tool (here 'git') isn't installed in a root-managed path (like /usr/bin), there is no way to add it (any request you could make, like a symlink from /usr/bin to your git executable, would be considered as a security risk).

The only solution I have came across was to compile one's own ssh (running with one's own account) in order to accommodate a local installation of a tool.
That is what I have implemented in the GitHub project compileEverything (which compiles, amongst other tools, an ssh daemon).

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top