I am currently trying to set up the post-commit hook for my subversion repository to send a email notifications. I am using subversion 1.7.8. My post-commit hook script is as follows:
#!/bin/sh
REPOS="$1"
REV="$2"
"$REPOS"/hooks/mailer.py commit $REPOS $REV "$REPOS"/mailer.conf
When I make a commit the following error message is produced:
Traceback (most recent call last):
File "/lib/python2.7/site.py", line 563, in <module>
main()
File "/lib/python2.7/site.py", line 545, in main
known_paths = addusersitepackages(known_paths)
File "/lib/python2.7/site.py", line 278, in addusersitepackages
user_site = getusersitepackages()
File "/lib/python2.7/site.py", line 253, in getusersitepackages
user_base = getuserbase() # this will also set USER_BASE
File "/lib/python2.7/site.py", line 243, in getuserbase
USER_BASE = get_config_var('userbase')
File "/lib/python2.7/sysconfig.py", line 521, in get_config_var
return get_config_vars().get(name)
File "/lib/python2.7/sysconfig.py", line 420, in get_config_vars
_init_posix(_CONFIG_VARS)
File "/lib/python2.7/sysconfig.py", line 299, in _init_posix
raise IOError(msg)
IOError: invalid Python installation: unable to open //include/python2.7/pyconfig-32.h (No such file or directory)
The peculiar thing about this error is that when I run post-commit myself on the command-line (with the appropriate arguments) no errors are produced, and I receive the desired email notification. This makes me think the error is not related to my mailer.conf file.
Does anyone have any idea what could be causing this error?
Thanks, Jamie.
CORRECTION:
I thought that running svnserve under root fixed the problem locally but after further experimentation I realise that this is wrong. post-commit works on the local machine if the project was checked out using the file:// syntax but fails if checked out using the svn:// syntax.
Therefore, the problem only arises when svnserve tries to run post-commit, regardless of whether it is running under root or not, or the client is on the same or a different machine.
There could be many possible reasons why your hook isn't firing:
- For security reasons, Subversion hook scripts are run without any environment variables being set. So, set the environment variables in the hook, and use absolute paths for running applications
- Network drive mappings are user specific. Ensure that the drives exist for the user account under which the SVN server is running
- Hooks don't execute from the
hooks/
folder, they execute from the root server's folder
More info:
Hope this helps.
来源:https://stackoverflow.com/questions/18214883/post-commit-hook-produces-error-on-svn-commit-but-works-when-run-on-manually-on