As HOME usually isn’t set on windows, the existence of the variable
could indicate that the user would like to override the windows
default. I would thus check for HOME first.
Also, under cygwin ruby all three variables are set, but APPDATA and
USERPROFILE are “inherited” from the windows environment and are by
default set as Windows path while HOME usually is set as cygwin path.
In certain situations, this could cause certain difficulties, eg when
calling external programs.
It seems the trick with chdir doesn’t work when neither HOME nor
LOGDIR is set – as it is usually the case under Windows, I think.