Svn Post-Commit Troubleshooting

1 minute read,

We use Subversion (cygwin svnservice flavor).  I recently updated our source code repository server here at Bit Armory.  One thing is for sure, Cygwin updates never work like Microsoft updates.  Anytime I’ve updated Cygwin, it has always broken something.  For instance, today, my recent Cygwin update broke the Svn post-commit script that sends out an email to the developers on a source code check-in.  So, what was the problem?

Cygwin updates scripts tend to break things by reapplying (resetting) permissions on the binary directories (/bin, /usr/sbin …etc…).  When permissions are reapplied, accounts such as the SYSTEM service account loose execution rights.  So, if your svnservice is being run by cygrunsrv under a SYSTEM service account (yes, I know, it shouldn’t be running under SYSTEM), you’ll run into a lot of errors if you try to execute cygwin applications from the SYSTEM account.  So, as it turns out, the lack of the execution “chmod ugo+x” on svnlook.exe and other supported files caused the post-commit script to fail.

Here are some important tips / tricks that I use to help keep cygwin setup tame.

Set Execute Permissions

Make sure all programs / scripts you intend to run (and any child processes / scripts that are run as a consequence) have execute permissions.  For example in my case:

  • svnlook.exe
  • sendmail.exe
  • ssmtp.exe
  • perl.exe
  • post-commit

Simulate svnserve launching post-commit

Simulate svnserve executing your post-commit script file by using:

$env - /bin/sh /path-to-svn-repo/Project/hooks/post-commit
    /path-to-svn-repo/Project X

where X is a revision number.  “env -“ launches a process with an empty environment just like svnserve does.  This means you need to setup %path% environment variables for your script to run. You can take this one step further and load this as a system service by using:

cygrunsrv --install svntest --path /bin/env.exe --args "- /bin/sh
    /path-to-svn-repo/Project X"
net start svntest

and then check /var/log/svntest.log for any critical errors.  Can’t get any more simulated than that.

Use strace

Use strace to trace svnserve by executing:

strace.exe svnserve.exe args > output.txt

And you’ll get some decent output on how svnserve.exe is running.  Search for post-commit in output.txt, errors, and failures.

Use Filemon

You can also use Filemon/ProcessMonitor from and watch the svnserve.exe process on a windows machine for any weird errors and anything that looks suspicious.

Hope that helps.  Happy coding! :sunglasses:


Leave a comment

Your email address will not be published. Required fields are marked *