From 2aa00da41be2f82358cdc9be0cfb83c6f9b28c15 Mon Sep 17 00:00:00 2001 From: Jan De Dobbeleer Date: Sat, 10 Jul 2021 14:57:42 +0200 Subject: [PATCH] fix(windows): try HOME by default for user home --- src/environment_windows.go | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/environment_windows.go b/src/environment_windows.go index 66c293d1..6cee4e4b 100644 --- a/src/environment_windows.go +++ b/src/environment_windows.go @@ -44,11 +44,12 @@ func (env *environment) isRunningAsRoot() bool { } func (env *environment) homeDir() string { - // return the right HOME reference when using MSYS2 - if env.getShellName() == bash { - return os.Getenv("HOME") + home := os.Getenv("HOME") + if len(home) > 0 { + return home } - home := os.Getenv("HOMEDRIVE") + os.Getenv("HOMEPATH") + // fallback to older implemenations on Windows + home = os.Getenv("HOMEDRIVE") + os.Getenv("HOMEPATH") if home == "" { home = os.Getenv("USERPROFILE") }