Skip to content

Commit fa1a3ae

Browse files
committed
Make gitea work using cmd.exe again
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 0a85537 commit fa1a3ae

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
@@ -6,6 +6,7 @@ package setting
66

77
import (
88
"encoding/base64"
9+
"errors"
910
"fmt"
1011
"math"
1112
"net"
@@ -465,6 +466,12 @@ func getAppPath() (string, error) {
465466
appPath, err = exec.LookPath(os.Args[0])
466467
}
467468

469+
if err != nil {
470+
if !errors.Is(err, exec.ErrDot) {
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)