All Windows environment variables are imported when Cygwin starts.Apart from that, you may wish to specify settings of several importantenvironment variables that affect Cygwin's operation.
TheCYGWIN
variable is used to configure a few globalsettings for the Cygwin runtime system. Typically you can leaveCYGWIN
unset, but if you want to set one ore moreoptions, you can set it using a syntax like this, depending on the shellin which you're setting it. Here is an example in CMD syntax:
C:\>
set CYGWIN=error_start:C:\cygwin\bin\gdb.exe glob
This is, of course, just an example. For the recognized settings of theCYGWIN
environment variable, seethe section called “TheCYGWIN
environmentvariable”.
Locale support is controlled by theLANG
andLC_xxx
environment variables. For a more detailed descriptionseethe section called “Internationalization”.
ThePATH
environment variable is used by Cygwinapplications as a list of directories to search for executable filesto run. This environment variable is converted from Windows format(e.g.C:\Windows\system32;C:\Windows
) to UNIX format(e.g.,/cygdrive/c/Windows/system32:/cygdrive/c/Windows
)when a Cygwin process first starts.Set it so that it contains at least thex:\cygwin\bin
directory where "x:\cygwin
is the "root" of yourcygwin installation if you wish to use cygwin tools outside of bash.This is usually done by the batch file you're starting your shell with.
TheHOME
environment variable is used by many programs todetermine the location of your home directory. This environment variable,if it exists, is converted from Windows format when a Cygwin process firststarts. However, it's usually set in the shell profile scripts in the /etcdirectory, and it'snot recommended to setthe variable in your Windows environment.
TheTERM
environment variable specifies your terminaltype. It is automatically set tocygwin
if you havenot set it to something else.
TheLD_LIBRARY_PATH
environment variable is used bythe Cygwin functiondlopen ()
as a list ofdirectories to search for .dll files to load. This environment variableis converted from Windows format to UNIX format when a Cygwin processfirst starts. Most Cygwin applications do not make use of thedlopen ()
call and do not need this variable.
TheGMON_OUT_PREFIX
environment variable is helpfulin some situations when profiling Cygwin programs. For more information,seethe section called “Profiling programs that fork”. Only software developers with aneed to profile their programs have a use for this variable.
In addition toPATH
,HOME
,LD_LIBRARY_PATH
, andGMON_OUT_PREFIX
,there are three other environmentvariables which, if they exist in the Windows environment, areconverted to UNIX format:TMPDIR
,TMP
,andTEMP
. The first is not set by default in theWindows environment but the other two are, and they point to thedefault Windows temporary directory. If set, these variables will beused by some Cygwin applications, possibly with unexpected results.You may therefore want to unset them by adding the following two linesto your~/.bashrc
file:
unset TMPunset TEMP
This is done in the default~/.bashrc
file.Alternatively, you could setTMP
andTEMP
to point to/tmp
or toany other temporary directory of your choice. For example:
export TMP=/tmpexport TEMP=/tmp
There is a restriction when calling Win32 API functions whichrequire a fully set up application environment. Cygwin maintains its ownenvironment in POSIX style. The Win32 environment is usually strippedto a bare minimum and not at all kept in sync with the Cygwin POSIXenvironment.
If you need the full Win32 environment set up in a Cygwin process,you have to call
#include <sys/cygwin.h>cygwin_internal (CW_SYNC_WINENV);
to synchronize the Win32 environment with the Cygwin environment.Note that this only synchronizes the Win32 environment once with theCygwin environment. Later changes using thesetenv
orputenv
calls are not reflected in the Win32environment. In these cases, you have to call the aforementionedcygwin_internal
call again.