-
-
Notifications
You must be signed in to change notification settings - Fork 5.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Can't execute gitea.exe on Windows in cmd.exe #22063
Comments
Duplicate of #21943 NOTE: it might have been premature to close the other issue as it just captures a "workaround" not the change in behaviour (or regression...) |
but it still runs as windows service as previously. |
I wonder if this would fix this? diff --git a/modules/setting/setting.go b/modules/setting/setting.go
index f0d7f0292..6d99ffa0f 100644
--- a/modules/setting/setting.go
+++ b/modules/setting/setting.go
@@ -6,6 +6,7 @@ package setting
import (
"encoding/base64"
+ "errors"
"fmt"
"math"
"net"
@@ -465,6 +466,13 @@ func getAppPath() (string, error) {
appPath, err = exec.LookPath(os.Args[0])
}
+ if err != nil {
+ if !errors.Is(err, exec.ErrDot) {
+ return "", err
+ }
+ appPath, err = os.Getwd()
+ appPath = filepath.Join(appPath, os.Args[0])
+ }
if err != nil {
return "", err
}
|
The trouble is I can't test this because I don't run windows. |
If I can figure out how to cross compile in Gentoo , I can test |
|
ok so it looks like my patch does work! Right I'll try to clean it up a bit and push it up as a fix. |
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>
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>
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 <art27@cantab.net>
Backport #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>
Description
From powershell it starts normally.
And it' working as expected in cmd.exe for 1.17.3
Gitea Version
1.18-rc1
Can you reproduce the bug on the Gitea demo site?
No
Log Gist
No response
Screenshots
No response
Git Version
No response
Operating System
Windows 11
How are you running Gitea?
Official gitea-1.18.0-rc1-windows-4.0-amd64.exe
Database
None
The text was updated successfully, but these errors were encountered: