0

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.

1 Answers1

0

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.

bahrep
  • 29,961
  • 12
  • 103
  • 150
Sameer Singh
  • 1,358
  • 1
  • 19
  • 47
  • Running svnserve as root seems to fix the error for commits on the server computer but I have just found out that it still occurs for clients on other computers :S Is it svnserve that runs the post-commit hook? If so, why should it matter which client makes the commit? – Jamie Fairbrother Aug 14 '13 at 13:30
  • So, `svnserve` is running as root and acting as the actual server? If so, then that is bizarre because it should be the one running the post-commit hook without any issues. – Sameer Singh Aug 14 '13 at 13:39
  • Actually, my description of the problem in the comment above was wrong. See the correction in the original question. – Jamie Fairbrother Aug 14 '13 at 16:31
  • Replacing the line `"$REPOS"/hooks/mailer.py commit $REPOS $REV "$REPOS"/mailer.conf` by `\usr\bin\python2.7 "$REPOS"/hooks/mailer.py commit $REPOS $REV "$REPOS"/mailer.conf`, that is using the full path for Python seemed to fix the problem. Thanks a lot! – Jamie Fairbrother Aug 15 '13 at 09:14
  • Nice! Happy to help. :) – Sameer Singh Aug 15 '13 at 10:38