Set environment variables

Environment variables are used by many programs to read in additional information at startup. E.g. the PATH environment variable tells the shell where to look for executables, thus allowing you to run many programs without having to specify the full path of the binary.

Windows NT and its successors know two types of environment variables: System variables can be changed only by the administrator and affect all users, whereas user variables affect only the user who set them for his own environment. Both are set in the System applet of the System settings group. Select the "Environment" tab in the pop-up dialog and click on the entry that you want to edit. The present value of the variable will be displayed in a separate edit field. Change the value or append new values to the semicolon-separated list. Click Set (clicking OK alone is not sufficient). To create a new environment variable, enter a new name into the provided edit field, and set a value as described above.

For Emacs as well as for command line windows, the environment variables are evaluated only once: when the window is opened first. If you change environment variables as described, they will have no effect on command line windows that are already open. So to see the effects of added or changed environment variables, you'll have to close and reopen any command line windows.

On Windows 95/98/ME, all environment variables are set in the autoexec.bat file with an entry like set VARIABLE=VALUE. You will have to reboot the computer to let the changes take effect.

The story about environment variables has an additional twist on Cygwin. The concept of a POSIX system on top of Windows requires that some things like paths are handled differently inside and outside of Cygwin. To keep both worlds happy, we will use the System settings to set variables which we need in Win32 and we will use the shell resource files to set things which we need only within Cygwin.

Note: This setup strategy comes at a small price: Cygwin applications that rely on the variables in the shell resource files may not work properly on a NT command line or in a DOS box. But I think with bash or any other fine shell at your hands this isn't really a loss.

For bash, the relevant resource files are /etc/profile, $HOME/.profile, $HOME/.bashrc, and $HOME/.bash_profile. Consult the manpages if you prefer a different shell. In one of these files PATH should be modified to prepend /usr/bin and /usr/local/bin (this is the default in /etc/profile) and probably also $HOME/bin/ which is a good place for your shell scripts. This ensures that the Cygwin version of any program gets called instead of a native Win32 program with the same name.

In the instructions below I'll use /etc/profile as the system-wide resource file. Keep in mind that you can always opt to put these settings in personal resource files or in the system settings (with the above caveats).