From 281af9a03d5a35d3a40162320bd6bc35139b1e6a Mon Sep 17 00:00:00 2001 From: Rui Lopes Date: Mon, 31 Aug 2020 13:35:15 +0100 Subject: [PATCH] prefer $APPDATA over $HOME in Windows (#9830) --- packer/config_file.go | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/packer/config_file.go b/packer/config_file.go index bf6c8637c..8078aaa4b 100644 --- a/packer/config_file.go +++ b/packer/config_file.go @@ -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 }