71

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 ?

bahrep
  • 29,961
  • 12
  • 103
  • 150
Permana
  • 1,972
  • 2
  • 33
  • 51
  • 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 May 10 '17 at 19:00

16 Answers16

197

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.

divinedragon
  • 5,105
  • 13
  • 50
  • 97
tatianes
  • 1,979
  • 1
  • 11
  • 3
36

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.

  • Just running clean-up worked for me but this was after logging off and on again so may have killed the process that way. – Nigel B Apr 10 '13 at 09:25
  • I had Visual Studio running with AnkhSVN and had to close that also before cleanup would work. – xenoclast Jun 28 '13 at 10:27
  • 2
    After a lot of searching i finally found this. This should be more visible as it's the only thing that worked for me! – JohanLejdung Jul 01 '13 at 09:22
22

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

Prince
  • 1,280
  • 3
  • 25
  • 52
  • 2
    "working directory locked" error may arise due to there is a lock by svn client at the time of folder/file ADD and not properly commit and it may be fix by cleanup. – Prince Apr 18 '13 at 17:07
  • 1
    I got the same error when i didn't run cleanup in the top directory level – Vincent Nov 05 '13 at 07:49
  • 4
    +1 for *“at the top directory level”*. Nobody else mentiones it and it seems to be important. – Melebius Jan 30 '14 at 17:05
11

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

sgupta
  • 535
  • 4
  • 8
7

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!

Alexis Pigeon
  • 7,423
  • 11
  • 39
  • 44
hackintosh152
  • 71
  • 1
  • 2
5

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.

Sadikhasan
  • 18,365
  • 21
  • 80
  • 122
3

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'.

Shirish
  • 31
  • 1
3

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

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

Ram Balwad
  • 269
  • 1
  • 4
  • 11
1

Tortoise svn ->clean up

Thats all in SVN

prashant thakre
  • 5,061
  • 3
  • 26
  • 39
1

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.

LivCool
  • 253
  • 1
  • 12
1

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

Permana
  • 1,972
  • 2
  • 33
  • 51
0

For PHPStorm or Intellij:

VCS -> Cleanup Project
Frank Roth
  • 6,191
  • 3
  • 25
  • 33
0

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.

KrishPrabakar
  • 2,824
  • 2
  • 31
  • 44
0

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

Alan Fletcher
  • 310
  • 1
  • 4
-1
svn cleanup test-lalala/
svn update

repeat twice

Liam
  • 27,717
  • 28
  • 128
  • 190
zero8
  • 1,997
  • 3
  • 15
  • 25