Skip to content

Commit

Permalink
Make gitea work using cmd.exe again
Browse files Browse the repository at this point in the history
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 <art27@cantab.net>
  • Loading branch information
zeripath committed Dec 8, 2022
1 parent 0a85537 commit fa1a3ae
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions modules/setting/setting.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ package setting

import (
"encoding/base64"
"errors"
"fmt"
"math"
"net"
Expand Down Expand Up @@ -465,6 +466,12 @@ func getAppPath() (string, error) {
appPath, err = exec.LookPath(os.Args[0])
}

if err != nil {
if !errors.Is(err, exec.ErrDot) {
return "", err
}
appPath, err = filepath.Abs(os.Args[0])
}
if err != nil {
return "", err
}
Expand Down

0 comments on commit fa1a3ae

Please sign in to comment.