From 1c762a465252746720dabe29e0f17b5d0ff3bdb8 Mon Sep 17 00:00:00 2001 From: Ran Vaknin Date: Mon, 8 Aug 2022 16:55:31 -0700 Subject: [PATCH 1/2] added fallback in case home is not set --- config/shared_config.go | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/config/shared_config.go b/config/shared_config.go index 835d71fbc37..45f0f3ef923 100644 --- a/config/shared_config.go +++ b/config/shared_config.go @@ -8,6 +8,7 @@ import ( "io" "io/ioutil" "os" + "os/user" "path/filepath" "strings" "time" @@ -1149,8 +1150,18 @@ func (e CredentialRequiresARNError) Error() string { func userHomeDir() string { // Ignore errors since we only care about Windows and *nix. - homedir, _ := os.UserHomeDir() - return homedir + home, _ := os.UserHomeDir() + + if len(home) > 0 { + return home + } + + currUser, _ := user.Current() + if currUser != nil { + home = currUser.HomeDir + } + + return home } func oneOrNone(bs ...bool) bool { From d3de722dd92d87c729dabadede769f461ffb623e Mon Sep 17 00:00:00 2001 From: Sean McGrail <549813+skmcgrail@users.noreply.github.com> Date: Thu, 11 Aug 2022 18:40:12 -0700 Subject: [PATCH 2/2] Add CHANGELOG.md entry --- .changelog/f6aec06ae77b40118322f509f6ad4096.json | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 .changelog/f6aec06ae77b40118322f509f6ad4096.json diff --git a/.changelog/f6aec06ae77b40118322f509f6ad4096.json b/.changelog/f6aec06ae77b40118322f509f6ad4096.json new file mode 100644 index 00000000000..a9479060b4e --- /dev/null +++ b/.changelog/f6aec06ae77b40118322f509f6ad4096.json @@ -0,0 +1,8 @@ +{ + "id": "f6aec06a-e77b-4011-8322-f509f6ad4096", + "type": "feature", + "description": "Add alternative mechanism for determning the users `$HOME` or `%USERPROFILE%` location when the environment variables are not present.", + "modules": [ + "config" + ] +} \ No newline at end of file