70
votes

I'm developing a web using subversion as version control, but got "working directory locked" error message

Here's the story:

I have

PC-A:

  • Windows XP Pro
  • VisualSVN 2.5.2
  • Tortoise SVN 1.7.3

PC-B:

  • Windows XP Home
  • Tortoise SVN 1.7.3

I have create repository on PC-A using VisualSVN.

From PC-B, I Checkout http:\\PC-A:81\svn\test\trunk to D:\xampp\htdocs\test-lalala.

From PC-A, I also checkout http:\\PC-A:81\svn\test\trunk to D:\xampp\htdocs\test-lalala.

I Create a post-commit hooks running my-post-commit.bat file so when I commit to http:\\PC-A:81\svn\test\trunk, folder D:\xampp\htdocs\test-lalalaon PC-A will updated, so other people can see the result.

"C:\Program Files\VisualSVN Server\bin\svn.exe" update "D:\xampp\htdocs\test-lalala" --username myusername --password mypassword --config-dir "C:\Program Files\VisualSVN Server\conf" 

On PC-B, Create index.php file, and commit. When I commit, I get this error message

error message

On PC-A, I try to right-click on D:\xampp\htdocs\test-lalala TortoiseSVN > CleanUp, and check "cleanup working copy status" and "Include externals" (checked by default). Try to add file and commit, but still got the same error message.

I try to look for lock file on .svn folder but there are no lock file. I also try to delete working copy on PC-A D:\xampp\htdocs\test-lalala and checkout again, but when I commit, still got the same error message.

How to solve this error message? So when I commit, the folder will updated automatically ?

16
Jonathon J Howey's answer worked for me. I had to do one more thing, that is close my visual studio before clean up.saquib adil

16 Answers

196
votes

Every time I get a Working copy locked error I run a "Clean up". After that everything is back to normal.

On the command line you can execute svn cleanup which also removes lock files.

Note: Perform this operation on one level up directory and that should resolve most of the times.

36
votes

To anyone still having this issue (Error: Working copy '{DIR}' locked.), I have your solution:

I found that when one of TortoiseSVN windows crash, it leaves a TSVNCache.exe that still has a few handles to your working copy and that is causing the Lock issues you are seeing (and also prevents Clean Up from doing it's job).

So to resolve this:

Either

1a) Use Process Explorer or similar to delete the handles owned by TSVNCache.exe

1b) ..Or even easier, just use Task Manager to kill TSVNCache.exe

Then

2) Right click -> TortoiseSVN -> Clean up. Only "Clean up working copy status" needs to be checked.

From there, happy updating/committing. You can reproduce Lock behavior by doing SVN Update and then quickly killing it's TortoiseProc.exe process before Update finishes.

22
votes

Run a "Clean up" at the top directory level.

11
votes

I solved it by deleting WC_Lock record in the SQLite ".svn\wc.db" file lock record in the WC_LOCK table.

Just open "wc.db" file with SQLite editor and executed

delete from WC_LOCK

The solution was given in another link that I cannot find right now. But really quite a fix; without worrying about deleting all directories

7
votes

I fixed it by deleting the hidden .svn folder and replaced it with the fresh checkout .svn and it worked. Probably this hidden folder got messed up!

5
votes

I am sure It working fine for you

Goto top level SVN folder.

Right Click on folder(that has your svn files) -> TortoiseSVN -> CleanUp

This will surely solve your problem.

3
votes

If you are Windows guy and using "Tortoise SVN' user.

Select the File. Right Click. Option 'Tortoise SVN' --> get Lock. Use option 'Steal The Lock'.

3
votes

You can fix it with only one step.

Step 1 : Open terminal and go to your project then fire command "svn cleanup" then "svn update"

1
votes

I ended up using export command rather than update command. This is the post-commit hook

"C:\Program Files\VisualSVN Server\bin\svn.exe" export "D:\xampp\htdocs\test-lalala" --quiet --non-interactive --force --username myusername --password mypassword

1
votes

error "working copy locked", Just follow the steps :

  1. In which directory you are getting error on update
  2. Go to its parent directory
  3. In parent directory go to ".svn" hidden directory
  4. Remove file with name "lock"
  5. Clean up and Done

You can update the svn properly without error

1
votes

Tortoise svn ->clean up

Thats all in SVN

1
votes

As you get working copy error, Just run the svn cleanup which clean all the unwanted files and folders. If still error comes, then do one thing.

Copy your files to other drive and delete the working copy folder or file and then take a update it will fetch the fresh file and after this replace with your updated copy and commit the same.

0
votes

I have experienced the same issues as you described. It appears to be a bug on Tortoise 1.7.3. I have reverted back to 1.7.2, executed a cleanup and an update. Now my SVN/Tortoise is working fine again

0
votes

For PHPStorm or Intellij:

VCS -> Cleanup Project
0
votes

Is your BitLocker disk encryption running? In my case, it locked the whole drive of the disk for encryption, and SVN failed with this error.

-1
votes
svn cleanup test-lalala/
svn update

repeat twice