Skip to content

“cvs checkout: failed to create lock directory” solution

For those of us still using CVS, rather than the highly acclaimed subversion, I wanted to outline a solution to a common problem I’ve often seen:

One user creates a cvs module (named, for example, project) and checks in a number of files and directories. Then another developer tries to check out the module and sees this error. (Here’s another explanation of the solution.)

: cvs checkout: failed to create lock directory for
`/usr/local/cvsrepo/project'
(/usr/local/cvsrepo/project/#cvs.lock): Permission denied
: cvs checkout: failed to obtain dir lock in repository
`/usr/local/cvsrepo/project'
: cvs [checkout aborted]: read lock failed - giving up

If you go to /usr/local/cvsrepo/project, and run an ls -l, you’ll see that the permissions look like:

...
drwxrwxr-x 2 user group 4096 Feb 16 09:40 bin
...

This error message comes from the fact that the second user is not a member of group group. The best way to solve this is to create a second group, perhaps called cvs, and assign both users to that group.

Then, you want to make sure that all the files have the correct group bit set:
chown -R :cvs /usr/local/cvsrepo/project

And, you want to make sure that any new directories (and files) added use the cvs group, rather than the group group:
chmod -R g+ws /usr/local/cvsrepo/project

Your final permissions should look like:
...
drwxrwsr-x 2 user cvs 4096 Feb 16 09:40 bin
...

Now the second user and any other developers should be able to check out the code so safely stored in cvs.

29 thoughts on ““cvs checkout: failed to create lock directory” solution

  1. Pradeep says:

    Hats Off Great work!
    Timely Help..

  2. surendra kumar says:

    you saved my life man…!
    hats off
    thanks for the post man.

  3. moore says:

    All,

    Glad to help!

  4. Krishen says:

    This just helped me out too on my Leopard-based CVS server! Thanks!

  5. Joe says:

    Excellent post. Thanks.

  6. Vaibhav says:

    Thank you !
    This post helped me a lot.

  7. Simon Long says:

    Thanks. This was a great help.
    Keep up the good work.

  8. Dilesh says:

    Good timely help while implementing cvs. Thank you.

  9. Chris says:

    Perfect, thanks a bunch!

  10. Febin says:

    Geat………Great Help Man

  11. Alexandre says:

    Nice post!
    Exactly what I needed.
    Thanks a lot

  12. aretusa says:

    Great, thanks!!!

  13. Prasanna V says:

    Very thankful to you,
    It just worked swiftly.

  14. freshbee says:

    I too faced the same problem, but in my case two groups just need to check out each others directory. So its simple just give permissions such as 775 to the directories.
    But yet the problem wasn’t solved.
    The reason was /var/lock/cvs/ need to have write permission to the user who does check out this directory.
    The problem solved.

  15. moore says:

    Freshbee,

    Awesome! Thanks for sharing your fix. I’ve never run into the situation where I needed two groups to be able to check out one source tree.

    So, am I correct in assuming you chmoded /var/lock/cvs to 777? That seems to be the only way to have two different groups have write permissions on one directory.

  16. Alex says:

    Thanks for the tip – exactly what I was looking for!

  17. Harry says:

    Thanks, you saved my life!

  18. anuj says:

    thanks. nice post…

  19. Prakash says:

    Very Helpful Post. Tnx!

  20. freshbee says:

    I too faced the same problem, but in my case two groups just need to check out each others directory. So its simple just give permissions such as 775 to the directories.
    But yet the problem wasn’t solved.
    The reason was /var/lock/cvs/ need to have write permission to the user who does check out this directory.
    The problem solved.

    —–

    if still the problem persists kindly check the file /CVSROOT/config,
    there u need to enable this field.
    # Put CVS lock files in this directory rather than directly in the repository.
    LockDir=/var/lock/cvs

    this says that the lock will not be created in the repository, but in the lock directory, where the user will have write provision.

  21. Pucik says:

    Hi all,
    I had this problem when working with cvs files on UNIX, that has someone else checkouted with WinCVS with windows CRLF.
    I had to change all those Repository files and it worked 🙂

    for i in `grep -r -Pl $’rn’ . | grep Repository`; do dos2unix -o $i; done

    Pucik

  22. amir says:

    In my case the problem was that a colleague had removed the specified directory from the repository (CVS doesn’t support this, but they went ahead and did it manually).

  23. stefan says:

    Thanks man, this helped a lot to solve the problem!

  24. Arunkumar says:

    cvs checkout: failed to create lock directory for `/cvs/dev/CVSROOT’ (/cvs/dev/CVSROOT/#cvs.history.lock): Permission denied

    The above mentioned is my error,so i have checked ls -l in this path /cvs/dev/CVSROOT/ but i am not getting any file “bin” in this list.Where to check the correct permissions guys….Kindly help as soon as possible.

  25. moore says:

    Can you show us the output of the “ls-l /cvs/dev/CVSROOT” command, as well as your username and group?

  26. Arunkumar says:

    It has too much of files which set of files do you need to check .i will screen it

     

  27. moore says:

    Whichever file you are trying to check in would be the best place to start.

Comments are closed.