From 001824b9f395dbc0248b4086c299f7b03a827853 Mon Sep 17 00:00:00 2001 From: Brent Baude Date: Tue, 13 Feb 2024 13:20:06 -0600 Subject: [PATCH] Windows uses USERPROFILE not HOME When dealing with environment variables that set $HOME, we do not get the desired result. Windows will honor USERPROFILE. [NO NEW TESTS NEEDED] Signed-off-by: Brent Baude --- pkg/machine/e2e/machine_test.go | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/pkg/machine/e2e/machine_test.go b/pkg/machine/e2e/machine_test.go index 866b23b878..f7af93ad17 100644 --- a/pkg/machine/e2e/machine_test.go +++ b/pkg/machine/e2e/machine_test.go @@ -147,6 +147,11 @@ func setup() (string, *machineTestBuilder) { if err := os.Setenv("HOME", homeDir); err != nil { Fail("failed to set home dir") } + if runtime.GOOS == "windows" { + if err := os.Setenv("USERPROFILE", homeDir); err != nil { + Fail("unable to set home dir on windows") + } + } if err := os.Setenv("XDG_RUNTIME_DIR", homeDir); err != nil { Fail("failed to set xdg_runtime dir") } @@ -203,4 +208,9 @@ func teardown(origHomeDir string, testDir string, mb *machineTestBuilder) { if err := os.Setenv("HOME", origHomeDir); err != nil { Fail("failed to set home dir") } + if runtime.GOOS == "windows" { + if err := os.Setenv("USERPROFILE", origHomeDir); err != nil { + Fail("failed to set windows home dir back to original") + } + } }