70

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 ?

1
  • Jonathon J Howey's answer worked for me. I had to do one more thing, that is close my visual studio before clean up. May 10, 2017 at 19:00

16 Answers 16

196

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.

3
  • 18
    worked for me when i cleaned up one directory level up from locked location
    – waqaslam
    Jan 3, 2013 at 12:14
  • It is working on Ubuntu, I have Ubuntu on Client and Linux on server and it works. Actually this problem happens to me on Linux more often than it was on Windows. Jun 10, 2015 at 1:20
  • 5
    Do not forget to check on "Break locks" check box if using GUI. Oct 9, 2017 at 7:42
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.

3
  • Just running clean-up worked for me but this was after logging off and on again so may have killed the process that way. Apr 10, 2013 at 9:25
  • I had Visual Studio running with AnkhSVN and had to close that also before cleanup would work.
    – xenoclast
    Jun 28, 2013 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! Jul 1, 2013 at 9:22
22

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

3
  • 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, 2013 at 17:07
  • 1
    I got the same error when i didn't run cleanup in the <b>top directory</b> level
    – Vincent
    Nov 5, 2013 at 7:49
  • 4
    +1 for “at the top directory level”. Nobody else mentiones it and it seems to be important.
    – Melebius
    Jan 30, 2014 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

2
  • Is DB Browser for SQL Lite the same as SQLLite editor?
    – user502187
    Mar 15, 2018 at 16:49
  • Yes, it should be. For me, I just normally use Firefox extension to edit DB
    – sgupta
    Jun 6, 2018 at 22:33
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!

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

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

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
  • those are two steps ;P ... or even three
    – D Ie
    Aug 21, 2018 at 14:09
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

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

1

Tortoise svn ->clean up

Thats all in SVN

2
  • 2
    Which often fails or cleans up indefinitely
    – Asu
    May 25, 2016 at 15:09
  • What if a user is faced with the problem and does not use TortoiseSVN after all?
    – Nico Haase
    Mar 5, 2019 at 10:48
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.

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

0

For PHPStorm or Intellij:

VCS -> Cleanup Project
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.

-1
svn cleanup test-lalala/
svn update

repeat twice

3
  • Can you explain that further? What does test-lalala stand for?
    – Nico Haase
    Mar 5, 2019 at 10:39
  • @NicoHaase That is the same name used in the question Mar 5, 2019 at 10:47
  • And what do you mean by "repeat twice"?
    – Nico Haase
    Mar 5, 2019 at 10:48

Not the answer you're looking for? Browse other questions tagged or ask your own question.