Skip to content

Commit 1805075

Browse files
committed
Make gitea work using cmd.exe again (go-gitea#22073)
Backport go-gitea#22073 Gitea will attempt to lookup its location using LookPath however, this fails on cmd.exe if gitea is in the current working directory. exec.LookPath will return an exec.ErrDot error which we can test for and then simply using filepath.Abs(os.Args[0]) to absolute gitea against the current working directory. Fix go-gitea#22063 Signed-off-by: Andrew Thornton <[email protected]>
1 parent 1409b34 commit 1805075

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

modules/setting/setting.go

+7
Original file line numberDiff line numberDiff line change
@@ -464,6 +464,13 @@ func getAppPath() (string, error) {
464464
appPath, err = exec.LookPath(os.Args[0])
465465
}
466466

467+
if err != nil {
468+
// FIXME: Once we switch to go 1.19 use !errors.Is(err, exec.ErrDot)
469+
if !strings.Contains(err.Error(), "cannot run executable found relative to current directory") {
470+
return "", err
471+
}
472+
appPath, err = filepath.Abs(os.Args[0])
473+
}
467474
if err != nil {
468475
return "", err
469476
}

0 commit comments

Comments
 (0)