prefer $APPDATA over $HOME in Windows (#9830)

This commit is contained in:
Rui Lopes 2020-08-31 13:35:15 +01:00 committed by GitHub
parent e4f975fae1
commit 281af9a03d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 7 additions and 3 deletions

View File

@ -22,12 +22,16 @@ func ConfigDir() (string, error) {
}
func homeDir() (string, error) {
// Prefer $HOME over user.Current due to glibc bug: golang.org/issue/13470
if home := os.Getenv("HOME"); home != "" {
// Prefer $APPDATA over $HOME in Windows.
// This makes it possible to use packer plugins (as installed by Chocolatey)
// in cmd/ps and msys2.
// See https://github.com/hashicorp/packer/issues/9795
if home := os.Getenv("APPDATA"); home != "" {
return home, nil
}
if home := os.Getenv("APPDATA"); home != "" {
// Prefer $HOME over user.Current due to glibc bug: golang.org/issue/13470
if home := os.Getenv("HOME"); home != "" {
return home, nil
}