Not sure if Git::Wrapper is helpful - I tried originally with this but was getting similar errors which was what drove me to simple system commands. I figured Git::Wrapper was just adding unnecessary complexity (since I don't know how it works) ?

I couldn't see any noticeable differences there? (but I really dont know what I'm looking for!)

In fact I did investigate environment variables earlier but couldn't find any references in the documentation to things that git needed setting (beyond the path to the git binary - let me know if anyone knows more on this?). At that time I compared command line/browser.

I discovered 'strace' on my google travels and added this. Not really sure how to analyse the output though! I wont post the full output as it is very long - but when it fails it starts

Very big hat off to the real wizard on google groups "git for human beings" who solved this conundrum (I wont say who as I haven't asked for permission - but you can find the thread under the title 'frustrations trying to control git through apache'). Here is an extract of his diagnosis:

So we see that:

1) The Git code is poorly documented, and there is no coding control
to ensure that the code is internally documented.

3) The error is triggered if fd 0 (standard-input) is closed when Git
starts and Git needs to put a file into the object store. In your
situation, that is determined by the particular Git operation and the
details of how Git is invoked by Apache.

From this, we can construct a simple test case that demonstrates the
bug:

So there you have it. Nothing to do with environment variables, and mod_perl was a red herring

The fix?

Add </dev/null to any (bash) line being executed that involves a write (or otherwise ensure standard input is not closed when git tries to open the file). Unfortunately this appears to mean *any* git module (Git::Wrapper, Git::Repository... ) is unusable for me (and I would be surprised if not for other people aswell?), and I must use home grown code...