Git pre-/post-receive hooks not working. No push messages in journal.
I was wondering why no git push requests where showing up in my repository. Turns out, that the pre-/post-receive hooks are installed in the hooks directory, but fail to execute.
Some debugging showed that the problem seems to be the Python virtual environment used for running RhodeCode. The pre-/post-receive hooks get executed without the virtual environment, thus starting under the server wide Python installation where RhodeCode is not installed in.
When pushing to the server the pre-/post-receive hooks fail with an ImportError, because the "RhodeCode" module cannot be imported. This import error is silently dropped, the repository is updated and the updates show up in RhodeCode. But no 'push' message shows up in the journal.
The virtual environment is already set within ~/.bashrc, which works fine on login, but fails for git push. I even tried ~/.profile without success.
I don't know, why the virtual env is not available when git executes the hooks.
EDIT 20120926: ignore the next part and the attached helper script 'setup-virtualenv-and-execute.sh', see next comment
To work around this problem for now, I temporaryly renamed the pre-/post-receive Python scripts into "pre-/post-receive.rhodecode" and created a script which checks whether or not the virtual environment is set. This script then sets the virtual environment and calls in turn the Python scripts. This works fine then, but has to be applied manually in each git repository.
I have attached this helper script including some information about the setup.