Background
Subversion is a version control system. It can run as either it’s own server (svnserve), or as an Apache module (mod_dav_svn.so).
When using the mod_dav_svn module for Apache, and doing an svn copy operation on the repository itself can fail if the VirtualHost configuration for subversion is not correct. Put simply, if Apache itself and mod_dav_svn are serving content from the same path, then conflicts can occur. Apache can get confused if it attempts to serve a physical file instead of routing the request through mod_dav_svn.
“svn copy …” operations will fail, while “svn update …”, “svn commit …”, and “svn checkout …” operations work fine.
Detail of the problem, diagnosing the problem, and the fix are below.
Problem
Repository checkouts (svn co …) and commits (svn ci …) work fine and throw no errors, but svn trunk copying operations fail “svn copy …/trunk …/tags/x.x” with “svn: Repository moved permanently to ‘…’; please relocate”.
$ svn co https://svn.test.com/myproject/trunk myproject
... (checkout progress)
Checked out revision [x].
$ svn ci myproject
Committed revision [x].
$ svn cp https://svn.test.com/myproject/trunk https://svn.test.com/myproject/tags/x.x
svn: Repository moved permanently to 'https://svn.test.com/myproject/'; please relocate
Diagnostics
To diagnose the problem, first make sure the local checkout urls are correct.
$ svn info myproject
...
URL: https://svn.test.com/myproject/trunk
Repository Root: https://svn.test.com/myproject
The Repository Root should match the root url of the project repository that you are working with because the svn commit above worked. However, if they don’t match, then use svn switch to move the url that your local checkout is linked to:
$ svn switch --relocate [OLD URL] [NEW URL] myproject
$ svn cp https://svn.test.com/myproject/trunk https://svn.test.com/myproject/tags/x.x
If relocating the base url of the checkout (svn switch –relocate …) does not fix the problem, but checkouts and commits work fine, the next step is to look at the virtual host configuration in Apache for the subversion module. This is where I found my problem.
The Cause
The file path of the subversion repository was within public_html, so it had a physical path that was identitical to it’s url path.
$ ls public_html
repos
$ cat /etc/httpd/conf.d/subversion.conf
<VirtualHost 127.0.0.1:443> #YOUR IP ADDRESS:PORT
DocumentRoot /home/svn/public_html #YOUR WEBROOT PATH
...
<Location /repos>
DAV svn
SVNParentPath /home/svn/public_html/repos #YOUR REPOSITORY PATH
...
</Location>
</VirtualHost>
The problem is that the Location is an actual physical filepath, not an alias. So, Apache isn’t sure whether to attempt to serve the physical file itself, or to pass the request through to mod_dav_svn. Most of the time mod_dav_svn wins and Apache forward the request through. However, “svn copy” must work slighly differently, and Apache attempts to serve the request itself, rather than pass it through mod_dav_svn. The request then fails and svn errors out with the “svn: Repository moved permanently to ‘…’; please relocate” message.
A reader of this blog also pointed out that this can also happen if you have an overlap between a URL path alias and the repos folder itself:
#Alias /repos “/srv/svn/repos” #Commenting this line out fixed the problem
Fix
The fix is to 1) change the Apache configuration, and 2) change the physical path to the repository so that it does not match the url. This way, Apache will never attempt to serve a physical file itself, and will instead forward the requests to mod_dav_svn.
Edit /etc/httpd/conf.d/subversion.conf
<VirtualHost svn.test.com:443>
DocumentRoot /home/svn/public_html
...
<Location /repos>
DAV svn
SVNParentPath /home/svn/repos #NOTE THAT repos IS NOW OUT OF THE PHYSICAL WEBROOT PATH
...
Move the repository directory out of the physical webroot path and restart Apache.
[svn /home/svn]$ mv public_html/repos .
[svn /home/svn]$ sudo service httpd restart
All your “svn copy” operations should work now.





Thanks so much for this article – that was exactly the problem we had!!
Greets – Max
Comment by Max — February 16, 2010 @ 9:14 am
Glad I could help!
Comment by Kris — February 16, 2010 @ 10:27 am
Issue solved.
Discovered one more way to reproduce this problem.
Alias /iarepos “/srv/svn/iarepos”
This should not have been there. Had tried commenting this before as well but may be the sequence of changes and tests were not well-coordinated.
Removing this solved the issue.
Comment by Shrenik — April 15, 2010 @ 3:03 am
Thanks for the note! I added it to the post as another think to look for.
Comment by Kris — April 15, 2010 @ 4:50 am
Hi all
I have a similar problem but when i try to do a svn checkout.
I get this error
:/var/www# svn co http://10.0.0.1/Prueba/trunk/ prueba
svn: Repository moved permanently to ‘http://10.0.0.1/Prueba/trunk/ prueba’; please relocate
How can i fix this??
Thanks
Comment by daniela — June 18, 2010 @ 6:16 am
I have tried to follow the instructions above but still haven’t succeeded to use my remote svn-activated WebDAV apache server [Apache/2.2.17 (Unix) DAV/2 SVN/1.6.16 Server at ... ] but have failed miserably, time and time again.
Even with setup on the remote WebDAV svn server as simple as:
DAV svn
SVNPath /opt/apache-2.2.17/httpd/Physics/webdav/SVN/repository
and using the following command on my local machine (xxx.yyy.zz replacing the actual part of the WebDAV URL)
svn import http://www.xxx.yyy.zz/webdav/SVN/repository
yields the error
svn: Repository moved permanently to ‘http://www.xxx.yyy.zz/webdav /SVN/repository/’; please relocate
After working in vain for days trying to set up svn on the WebDAV server I have to ask myself if it is worth the effort. How difficult can it be???
Grateful for any help,
Bo
Comment by Bo Thidé — April 4, 2011 @ 2:59 pm
Bo,
What is the file path that Apache serves files from if you visit http://www.xxx.yyy.zz/webdav?
If it is /opt/apache-2.2.17/httpd/Physics/webdav, then you likely have Apache and mod_dav_svn fighting over who will serve the requests. The fix, if this is the case, is to move your repository folder (…/repository) outside of …/httpd, and set the SVNPath to the new path to …/repository.
It’s just a guess, but that’s a problem that I have run into before.
-Kris
Comment by Kris — April 4, 2011 @ 11:48 pm
Thank so so much for this report and fix. Initially I had the svn-repo in /srv/svn and the webserver was pointing to /srv/www/. That DAV_SVN is having problems with HTTPD Aliases is written nowhere. Thank you very much.
Comment by sufferer — June 7, 2011 @ 4:36 pm
[...] in /etc/apache2/conf.d/subversion.conf is throwing up Apache's DAV SVN module (as described here). Browsing the repository in a random webbrowser is possible and does not throw any warnings or [...]
Pingback by HowTo: Apache2 and Subversion (SVN) with Access Control on openSUSE 11.4 — June 8, 2011 @ 4:27 am
[...] Having the SVN repository root in /srv/svn, the vhost root in /srv/www/ and declaring an alias /svn pointing to /srv/svn (Alias /svn "/srv/svn") in /etc/apache2/conf.d/subversion.conf is throwing up Apache’s DAV SVN module (as described here). [...]
Pingback by Problem with Apache2 and Subversion on openSUSE 11.4 solved | Torbjörn Klatt — June 8, 2011 @ 7:35 am
Thanks for the solution and the clear explanation. now I also understand the root cause of this problem.
Comment by Neill — June 17, 2011 @ 4:04 pm
Many thanks, this solved what was becoming a very irritating problem. I’d been using Codendi to manage my repositories. Moving the repos out, editing the config file and then making a symbolic link from the codendi location to the new repo location worked a treat. I just need to port the rest of my repos over having proved it on one.
Thanks again, Ian
Comment by Ian — July 11, 2011 @ 6:31 am