CVS: Set CVSROOT Environment Variable

Posted September 4, 2005 by wolf359 in UNIX software

This Tech-Recipes tutorial contains a simple tip for CVS that will save time. Since multiple CVS repositories can exist on the same system, CVS needs to know which one you want to use when you run the cvs program.


When running the cvs command, either the -d option must be used with the absolute path of the CVS repository (like /export/home/longname/programming/cvsroot), or the CVSROOT environment variable must be set with this value. Typing the cvsroot gets old quickly, so you will find that adding this variable to your environment will make the process easier.

Assuming you are running a Bourne-type shell (sh, ksh, bash, zsh, etc.) you can set this variable temporarily by running the following:

CVSROOT=/export/home/longname/progrmaming/cvsroot
export CVSROOT

(Note: You can condense this to one command in most shells other than sh with export CVSROOT=/path/to/cvsroot.)

Making this setting persistent is preferrable. Edit your .profile with your favorite editor [If it is not vi, then you are better off learning it. You will be glad you did (eventually).] Add the line or lines above. Once you have edited, it will take effect the next time you create a shell or when you source the file into the current shell as with the following:

. ./.profile

The Conversation

Follow the reactions below and share your own thoughts.