Wednesday, December 13, 2006

Issue of CRLF chars

I faced a very weird problem while I was trying to find log, check out or update files from the CVS repository. The following error message was flashed on the screen:
[myuserid@localhost java]$ cvs log .
myuserid@mycvshost's password:
cvs-1.11.17_p2 log: Logging .
: No such file or directoryopen directory /cvsroot/my/repository
cvs-1.11.17_p2 log: skipping directory
myuserid@mycvshost's password:
" but pserver says "/cvsroot/my/repository"/my/repository

I could sense that this might be related to some CRLF (Carriage Return-Line Feed) issue, as all the error lines seem to be starting with what look like end of string delimiters (":" or "\""). So to further clarify my doubt I redirected the output to a file and this is the exact error message I was getting:

cvs-1.11.17_p2 log: Logging .
cvs-1.11.17_p2 log: cannot open directory /cvsroot/my/repository^M: No such file or directory
cvs-1.11.17_p2 log: skipping directory
Protocol error: Root says "/cvsroot/my/repository^M" but pserver says "/cvsroot/my/repository"

Gotcha! You see those "^M" chars? I figured what was the problem. I had checked out all the files in my Win XP workstation, and FTPed the entire tree to my Linux box. That caused the whole issue!

To rectify that, do a dos2unix on all the files under each of the CVS directories. A simple script to do this task is given below:
for dir in `find . -name CVS -type d` ; do
dos2unix $dir/*

Remember: We are not doing a dos2unix on all the source files in those directories, rather we do dos2unix only on the CVS related files. Keep this in mind.

No comments: