From 7384b86e953a74cddd572f7dac1e9d4ea1b9ce06 Mon Sep 17 00:00:00 2001 From: Adrien Delorme Date: Fri, 4 Jan 2019 14:10:30 +0100 Subject: [PATCH] windows plugin: prioritize AppData over default user directory ( UserProfile ) It was the default behaviour before. It is also standard for a binary to use files from the AppData directory. ex: https://github.com/golang/oauth2/blob/c453e0c757598fd055e170a3a359263c91e13153/google/default.go#L104 More on home: https://en.wikipedia.org/wiki/Home_directory --- packer/config_file.go | 7 ++++++- website/source/docs/extending/plugins.html.md | 9 ++++++--- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/packer/config_file.go b/packer/config_file.go index f95914230..27e671283 100644 --- a/packer/config_file.go +++ b/packer/config_file.go @@ -44,12 +44,17 @@ func ConfigTmpDir() (string, error) { func homeDir() (string, error) { - // First prefer the HOME environmental variable + // Prefer $HOME over user.Current due to glibc bug: golang.org/issue/13470 if home := os.Getenv("HOME"); home != "" { log.Printf("Detected home directory from env var: %s", home) return home, nil } + if home := os.Getenv("APPDATA"); home != "" { + log.Printf("Detected home directory from env var: %s", home) + return home, nil + } + // Fall back to the passwd database if not found which follows // the same semantics as bourne shell u, err := user.Current() diff --git a/website/source/docs/extending/plugins.html.md b/website/source/docs/extending/plugins.html.md index b9477914f..e1667ce92 100644 --- a/website/source/docs/extending/plugins.html.md +++ b/website/source/docs/extending/plugins.html.md @@ -52,10 +52,13 @@ later, it will take precedence over one found earlier. 1. The directory where `packer` is, or the executable directory. -2. `~/.packer.d/plugins` on Unix systems or `%APPDATA%/packer.d/plugins` on - Windows. +2. The `$HOME/packer.d/plugins` directory, if `$HOME` is defined (unix) -3. The current working directory. +3. The `%APPDATA%/packer.d/plugins` if `%APPDATA%` is defined (windows) + +4. The `%USERPROFILE%/packer.d/plugins` if `%USERPROFILE%` is defined (windows) + +4. The current working directory. The valid types for plugins are: