diff options
author | zeripath <art27@cantab.net> | 2022-12-14 06:15:11 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-12-14 01:15:11 -0500 |
commit | 4fb2006ca1cba98fe3851901982a3ecab252cfe3 (patch) | |
tree | 0956d7f767bedc3ebb94c09df4ae7787ab931777 /modules/setting/setting.go | |
parent | 5aa854693fc6dbd77a83cb89c88e45a06413a697 (diff) | |
download | gitea-4fb2006ca1cba98fe3851901982a3ecab252cfe3.tar.gz gitea-4fb2006ca1cba98fe3851901982a3ecab252cfe3.zip |
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 <art27@cantab.net>
Signed-off-by: Andrew Thornton <art27@cantab.net>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-authored-by: techknowlogick <techknowlogick@gitea.io>
Diffstat (limited to 'modules/setting/setting.go')
-rw-r--r-- | modules/setting/setting.go | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/modules/setting/setting.go b/modules/setting/setting.go index 9f2f0933d4..47e0ae2cda 100644 --- a/modules/setting/setting.go +++ b/modules/setting/setting.go @@ -466,6 +466,13 @@ func getAppPath() (string, error) { } if err != nil { + // FIXME: Once we switch to go 1.19 use !errors.Is(err, exec.ErrDot) + if !strings.Contains(err.Error(), "cannot run executable found relative to current directory") { + return "", err + } + appPath, err = filepath.Abs(os.Args[0]) + } + if err != nil { return "", err } appPath, err = filepath.Abs(appPath) |