env::home_dir()
should use SHGetKnownFolderPath()
on windows. #28940
Closed
Description
At the moment, it first looks at %HOME%
, and then at %USERPROFILE%
. This is bad for two reasons:
-
The home directory will be different when run from an msys or cygwin terminal. Unless the program is specifically compiled to run in an msys/cygwin environment (they have their own target triples) then it should not be affected by
%HOME%
(only%USERPROFILE%
stores the home directory on windows). -
Environment variables may be overridden.
SHGetKnownFolderPath()
will always give the correct path to the user's home folder.