I am trying to configure svn with Phabricator. Everything seems to be working so far, except for commiting changes. When I try to commit any code, I get the following error message:
svn: E165001: Commit blocked by pre-commit hook (exit code 255) with no output.
Just to be clear, the error message in question is output by the svn client program. It seems to be sent from svnserve when it encounters various issues, such as not being able to run the hook for some reason. It doesn't have to be provided by the hook.
If I delete the pre-commit hook, the commits go through as expected.
For testing purposes, I have created an extremely simple hook, that looks like this:
#!/bin/sh
echo "testing" >&2
exit 1
I get the same error message when using this hook as well. This being the case, there is not much sense trying to solve for a more complicated script until this one can be made to work. It could very well be that by solving for this script, the original one will work as well. I have been testing with this script and all that I have posted in this question holds true for this script. Basically, at this point in time, the script I have presented really is the script I'm trying to make work.
I have disabled the Phabricator daemons, since otherwise the pre-commit script is overwritten by Phabricator.
The following is some information that I think may be helpful in solving this, based on what I've seen written about this error message so far:
- The repository is owned by phd, the user that is running svnserve.
- The pre-commit hook is set to be executable.
foven@phabricator:~$ sudo ls -la /var/repo/SVN/hooks/
total 60
drwxr-xr-x. 3 phd phd 4096 Nov 18 13:46 .
drwxr-xr-x. 6 phd phd 4096 Nov 18 11:27 ..
-rwxr-xr-x. 1 phd phd 2062 Oct 27 10:17 post-commit.tmpl
-rwxr-xr-x. 1 phd phd 1638 Oct 27 10:17 post-lock.tmpl
-rwxr-xr-x. 1 phd phd 2289 Oct 27 10:17 post-revprop-change.tmpl
-rwxr-xr-x. 1 phd phd 1567 Oct 27 10:17 post-unlock.tmpl
-rwxr-xr-x 1 phd phd 37 Nov 18 14:39 pre-commit
drwxr-xr-x. 2 phd phd 19 Nov 17 17:05 pre-commit-phabricator.d
-rwxr-xr-x. 1 phd phd 3426 Nov 12 15:59 pre-commit.tmpl
-rwxr-xr-x. 1 phd phd 2434 Oct 27 10:17 pre-lock.tmpl
-rwxr-xr-x. 1 phd phd 2786 Oct 27 10:17 pre-revprop-change.tmpl
-rwxr-xr-x. 1 phd phd 2122 Oct 27 10:17 pre-unlock.tmpl
-rwxr-xr-x. 1 phd phd 3163 Oct 27 10:17 start-commit.tmpl
- SELinux is disabled/set to permissive:
foven@phabricator:~$ sudo getenforce
Disabled
- I have run dos2unix on the pre-commit hook file:
foven@phabricator:~$ sudo dos2unix /var/repo/SVN/hooks/pre-commit
dos2unix: converting file /var/repo/SVN/hooks/pre-commit to Unix format...
- I can run the hook script from the command line as user phd:
[phd@phabricator ~]$ /var/repo/SVN/hooks/pre-commit
testing
Even with an empty environment, which apparently matches how svn hooks are run.
[phd@phabricator ~]$ env -i /var/repo/SVN/hooks/pre-commit
testing
- It seems like the script's shebang is correct:
[phd@phabricator ~]$ which sh
/bin/sh
[phd@phabricator ~]$ ls -la /bin/sh
lrwxrwxrwx. 1 root root 4 Aug 18 09:37 /bin/sh -> bash
[phd@phabricator ~]$ which bash
/bin/bash
- I can commit code if the hook is deleted.
- I can checkout code.
Update
Based on a discussion in the #svn IRC channel, I tried the following:
sudo svn mkdir file:///var/repo/SVN/TestFolder -m "Add test folder"
svn: E165001: Commit blocked by pre-commit hook (exit code 1) with output:
testing
So this implies that the hook can work and may not be at fault at all. Still not sure what the problem is though, so can't totally rule out the hook (could be the hook is mostly fine, but something needs to be changed for it to work with this configuration). It seems likely that the problem lies elsewhere though. Any help is welcome.
exit 1
toexit 0
? Keep in mind that for program exit codes0
is success and every other exit code is (generally) a failure of some kind. – Joel C