From c3ec9eeb4b5aa37e66ad115528b6708d438e9459 Mon Sep 17 00:00:00 2001 From: garethgeorge Date: Thu, 11 Jul 2024 01:41:03 -0700 Subject: [PATCH] fix: cannot run path relative executable errors on Windows --- internal/resticinstaller/resticinstaller.go | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/internal/resticinstaller/resticinstaller.go b/internal/resticinstaller/resticinstaller.go index f3d39b87..70c3b3f7 100644 --- a/internal/resticinstaller/resticinstaller.go +++ b/internal/resticinstaller/resticinstaller.go @@ -12,6 +12,7 @@ import ( "io" "net/http" "os" + "os/exec" "path" "runtime" "strings" @@ -237,11 +238,8 @@ func FindOrInstallResticBinary() (string, error) { // Search the PATH for the specific restic version. resticBinName := resticBinName() - for _, dir := range strings.Split(os.Getenv("PATH"), string(os.PathListSeparator)) { - candidatePath := path.Join(dir, resticBinName) - if _, err := os.Stat(candidatePath); err == nil { - return candidatePath, nil - } + if binPath, err := exec.LookPath(resticBinName); err == nil { + return binPath, nil } // Check for restic installation in data directory.