Ubuntu Server: Resolve Can’t Open ‘.svn/lock’ Permission Denied Error Tips, Tricks and Tutorials 05 DEC 2013

svn-logoIt’s rather frustrating when you are trying to execute an SVN command only to be rebuffed with the infamous “Can’t Open ‘.svn/lock’ : permission denied” error message string. Now this message is usually an indication that currently another session is running an SVN operation which is still in process, hence the locked message, but in the case that you are the only one running SVN commands on the box and this is the only terminal running all day, well then it’s understandable to be pretty annoyed.

But it turns out that there is another reason why this message might be rebuffing you – if you are currently not logged in as the user with rights to the files contained in the svn checkout, then needless to say you won’t have access to the .svn/lock file!

Obviously the resolution is to simply switch over to the correct user account and run the SVN command, but if you can’t, well then you could always just steal the rights to the checked out files, assuming you have sudo rights of course!

In practice:

# go to the path of your project

# reset ownership
# NOTE: replace apache.staff with your user and group
sudo find . -exec chown apache.staff {} \;

# reset permissions
# NOTE: replace ug+rw with your file permissions
sudo find . -exec chmod ug+rw {} \;

# Now you can run the cleanup command to repair your .svn folders
svn cleanup

Useful to know.

Related Posts:

About Craig Lotter

South African software architect and developer at Touchwork. Husband to a cupcake baker and father to two little girls. I don't have time for myself any more.