Skip to content

Commit 4fb2006

Browse files
zeripathlunnytechknowlogick
authored
Make gitea work using cmd.exe again (#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 #22063 Signed-off-by: Andrew Thornton <[email protected]> Signed-off-by: Andrew Thornton <[email protected]> Co-authored-by: Lunny Xiao <[email protected]> Co-authored-by: techknowlogick <[email protected]>
1 parent 5aa8546 commit 4fb2006

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

Diff for: modules/setting/setting.go

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

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

0 commit comments

Comments
 (0)