fix: cannot run path relative executable errors on Windows

This commit is contained in:
garethgeorge
2024-07-11 01:41:03 -07:00
parent f10b7d8308
commit 42a2a106f1
+3 -5
View File
@@ -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.