Is it possible to have cygwin ignore the Windows HOME environment variable

cygwin;

As part of installing EGit, I had to set a HOME environment variable in Windows. This caused a problem whereby cygwin considers the HOME environment variable in Windows more important than the value in /etc/passwd. As a result, cygwin thinks my HOME directory in cygwin has moved from its previous location to my Windows user profile folder. I'd rather keep my cygwin files separate as my user profile folder is cluttered enough already but it doesn't seem to be possible to do so.

Is there any way to have cygwin use the value from /etc/passwd instead of the HOME enviroment variable?

Best Answer

Edit /etc/profile and change the lines

# Set the user id
USER="$(id -un)"

to

# Set the user id
USER="$(id -un)"

# Set user home dir
HOME=$(eval echo "~$USER")

This forces Cygwin always to use the value from /etc/passwd. This is better than using Cygwin.bat because this applies to all login shells, no matter how they're spawned.