Skip to content

Commit

Permalink
fix: avoid erroring when $HOME is not defined (#3389)
Browse files Browse the repository at this point in the history
Signed-off-by: Austin Abro <[email protected]>
  • Loading branch information
AustinAbro321 authored Jan 9, 2025
1 parent 76f327c commit 2d5d063
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions src/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 2d5d063

Please sign in to comment.