From 2d5d063d213709944507149ac0716eef18be4a7f Mon Sep 17 00:00:00 2001 From: Austin Abro <37223396+AustinAbro321@users.noreply.github.com> Date: Thu, 9 Jan 2025 15:41:40 -0500 Subject: [PATCH] fix: avoid erroring when $HOME is not defined (#3389) Signed-off-by: Austin Abro --- src/config/config.go | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/config/config.go b/src/config/config.go index ca80f619b6..340f704a16 100644 --- a/src/config/config.go +++ b/src/config/config.go @@ -103,12 +103,11 @@ func GetAbsCachePath() (string, error) { // GetAbsHomePath replaces ~ with the absolute path to a user's home dir func GetAbsHomePath(path string) (string, error) { - homePath, err := os.UserHomeDir() - if err != nil { - return "", err - } - if strings.HasPrefix(path, "~") { + homePath, err := os.UserHomeDir() + if err != nil { + return "", err + } return strings.Replace(path, "~", homePath, 1), nil } return path, nil