What To Do When CVS Fails to Create Lock Directory

I'm posting this in the hopes that it helps someone out there with the same problem because I just KNOW how often you're adding files using CVS. It's the little spark that gets your juices flowing while sitting at work daydreaming about how much you can't wait to use CVS again.

Anyways, I was creating a new CVS module and adding the contents of some source code to the repository when I heard the sound of breaking glass that TortoiseCVS uses to indicate a problem (it's a rather lovely sound).

It seems I had some sort of network issue while adding files. No problem, I thought, I'll just add the files that haven't been added and then commit all the files.

Unfortunately, every time I tried commiting files I heard that dreaded breaking glass. My error message was something like:

cvs commit: failed to create lock directory for `/cvsroot/MyProject/SomeDirectory'
(/cvsroot/MyProject/SomeDirectory/#cvs.lock):
No such file or directory
cvs commit: lock failed - giving up
cvs [commit aborted]: lock failed - giving up

Well that's strange, the error message is having trouble creating a lock for the directory "SomeDirectory" because it doesn't exist. But when I use Tortoise CVS to add contents, it shows that everything has been added.

What I discovered is that CVS stores information about the state of the repository in local hidden folders named, you guessed it, "CVS". If something very bad happens, it's quite possible that the local information will get out of synch with the information on the server. That's exactly what I ran into.

To fix it, I copied my source tree to a new directory, deleted the old source tree, and ran a Checkout command to get the latest version that actually made it into the repository. Then I copied that set aside source tree over the one I had just checked out so that all the new files made it into the tree. That then showed that I still needed to add some files and directories to the CVS repository, which I did. Finally, a commit of the source tree worked flawlessly.

By the way, I'm a relative CVS rookie, though I've used it quite a bit. So if there was a better way to do this, let me know.

For a great tutorial on source control, check out Eric Sink's series Source Control HOWTO.

[Listening to: Chinese Burn (Forbidden City Remix) - Paul Van Dyk - Perspective CD2 (10:36)]

What others have said

Requesting Gravatar... Another Perpetual CVS Rookie May 30, 2005 11:10 AM
# re: What To Do When CVS Fails to Create Lock Directory
FYI: Another occasion where this happens is when you specify the wrong CVS root on a remote server and the module you are working with in your local workspace actually doesn't exist in that cvs root on the server end. In this case, just double check that you have specified the correct root.
Requesting Gravatar... Nathan Apr 13, 2006 8:45 AM
# re: What To Do When CVS Fails to Create Lock Directory
I got the error because the bloke that created the directories I was trying to check out set them to read only, thus I didn't have permission to write the lock needed for checkout. So make sure the permissions on the cvs folder are set correctly.
Requesting Gravatar... Manish Jain Apr 19, 2006 10:10 AM
# re: What To Do When CVS Fails to Create Lock Directory
This is realy help. I was facing this issue and tring to resolve from last 2 hour but not got the success.
These steps have worked and resolved my problem.

Thanks.
Requesting Gravatar... Craig Turner Jun 05, 2006 11:39 PM
# re: What To Do When CVS Fails to Create Lock Directory
In my instance I think this was caused because I'd copied a directory including the CVS directory for it and the repository got confused because the CVS data in the subdirectory was wrong. Thanks for pointing me in the right direction.
Requesting Gravatar... Dan Scholten Aug 31, 2006 1:45 PM
# re: What To Do When CVS Fails to Create Lock Directory
I'm having this problem except it is occuring when I try to check OUT the respository. Has anyone else experienced this?
Requesting Gravatar... PK Sep 12, 2006 3:11 AM
# re: What To Do When CVS Fails to Create Lock Directory
Thanks so much for posting this. I'm new at setting up a CVS repository and had no idea what to do when this error came up. The other comments helped, too. :)
Requesting Gravatar... timmster Dec 13, 2006 4:06 AM
# re: What To Do When CVS Fails to Create Lock Directory
Thanks for giving me a hint!

I have resolved my problem. Thank You!
Requesting Gravatar... Mukesh Jul 24, 2007 2:39 AM
# What To Do When CVS Fails to Create Lock Directory
The server reported an error while performing the "cvs commit" command.

: cvs server: failed to create lock directory for #cvs.lock): Permission denied

: cvs server: lock failed - giving up

: cvs [server aborted]: lock failed - giving up

Requesting Gravatar... Eddie Aug 13, 2007 1:55 PM
# re: What To Do When CVS Fails to Create Lock Directory
Works like a charm thanks much!

In windows I copied the moved the problem directory to my desktop.
Did a search on this directory for the hidden CVS folders. (make sure to choose search for hidden folders and files in the windows search dialog) Then deleted all the cvs folders.

Checked out the lastest stuff and copied over it. Then cvs worked fine.

Thanks!!

Requesting Gravatar... Agile Being Aug 21, 2007 11:47 PM
# re: What To Do When CVS Fails to Create Lock Directory
I Had similar problem. In my case the cvs checkout of only one of the directories did not work.

Based upon this Article & Comments i checked out the file permissions and
found out that the read-write attribs for that particular dir was 755 (which should have been 775). This caused the dir-lock failure. I changed the attribs to 775 and everything started working fine.

The problem is fixed, but i still am wondering how could the permissions get changed, since everything was working fine initially.
Requesting Gravatar... Leigh Mar 03, 2008 1:08 PM
# re: What To Do When CVS Fails to Create Lock Directory
I'm also using TortoiseCVS and this seemed to fix it. I was doing an Add Contents on a folder that did NOT exist in the repository and I THINK this was the problem.

Plus I was doing a TON of files so it would take forever and then frustration would hit. It looks like for me the problem was the directory creation in the repository failing when doing an Add Contents. If I added the directory and THEN did add contents all was well.

Thanks for the help!
Requesting Gravatar... Nate Mar 11, 2008 7:32 PM
# re: What To Do When CVS Fails to Create Lock Directory
I had the identical type of error message (with the only difference being the directory name.) If you are in Linux/RedHat/Fedora/etc. you can cd into the $CVSROOT and then cd into the directory above the directory that is causing the conflict.

When you do an ls -la, check the group owner. If you see a different group owner than the one you belong to, it probably means the directory in question needs to have its group ownership corrected (or you probably need to be added to a group that you don't belong to.) You can do a 'less' on /etc/group to see if you are in the group in question.
Requesting Gravatar... uj Jun 18, 2008 11:00 PM
# I have created new directories additional to the existing in CVS, but facing problem while adding new directories.suggestions?
I am new to use CVS.
I did cvs checkout , so in the existing directory list i have added new directories also. so while doing add new directories are not getting created. I am doing cvs add on command prompt / also tried with WinCVS tool.
Please guide how do i proceed?

Your help is much appreciated.

Thanks,
Uj
Requesting Gravatar... shipra Jul 02, 2008 4:32 AM
# siebspi_logn.exe encountered a problem and needed to close.
siebspi_logn.exe encountered a problem and needed to close.
(in citrix).this popup window is comming whenever opening citrix server , how to solve it
Requesting Gravatar... Mainak Jul 03, 2008 5:42 AM
# re: What To Do When CVS Fails to Create Lock Directory
reasons are the directory in CVS is deleted manually or has wrong permissions.

I solved it by creating a directory in the cvs by shell and doing a chmod 777 on it.

Hope this helps
Requesting Gravatar... Vinay Jul 09, 2008 1:33 AM
# re: What To Do When CVS Fails to Create Lock Directory

I am getting below error during the tagging. I tried changing the permission to 0777 for the directory in the repository. Any solution.

cvs tag: failed to create lock directory for cvs.lock_old/#cvs.lock): No such file or directory
cvs [tag aborted]: read lock failed - giving up
Requesting Gravatar... DanielN Aug 06, 2008 2:17 AM
# re: What To Do When CVS Fails to Create Lock Directory
Your tip also helped me in the right direction. I backed up and removed the whole folder, used cvs up -d and everything is great!

What do you have to say?

(will show your gravatar)
Please add 7 and 1 and type the answer here: