If I add SSH keys, I won't be able to log in. I get this error message:
[...io/gitea/cmd/serv.go:99 runServ()] [F] setup: Failed to connect to database: Failed to create directories: mkdir data: permission denied
in /var/log/gitea/serv.log.
To fix this, I have to replace
command="/usr/bin/gitea serv key-3 --config=/etc/gitea/app.ini"
with
command="GITEA_WORK_DIR=/var/lib/gitea /usr/bin/gitea serv key-3 --config=/etc/gitea/app.ini"
in .ssh/authorized_keys.
A quick check with strace shows, that gitea does a
chdir("/usr/bin")
followed by a
stat64("data", 0x11f99614) = -1 ENOENT (No such file or directory).
You can find this chdir in cmd/serv.go.
I don't get why this environment variable is defaulted to /usr/bin. By default it should be pwd.
I first tried to write
command="cd /var/lib/gitea && /usr/bin/gitea serv key-3 --config=/etc/gitea/app.ini"
and this (obviously) didn't work for this reason.
Can you post your gitea configuration file or at least tell me if the path to your database is absolute?
If it is absolute, then I think there is a bug. If it is relative, you should set the GITEA_WORK_DIR environment variable for the user running gitea as you already did, but in a more conventional place.
Is was relative. Thanks for that.
But this doesn't solve the unexpected behavior of GITEA_WOKR_DIR.
GITEA_WORK_DIR should be set yourself in your shell profile?
I agree the behavior should be for the default to be $PWD, not the name of the directory containing the binary.
GITEA_WORK_DIR should be set yourself in your shell profile?
Yes. But this isn't the point of this issue. Also, in my opinion it's not documentend well enough, that you should set GITEA_WORK_DIR.
I think it's fixed by #2192. Reopen if there is still issue
Most helpful comment
I agree the behavior should be for the default to be
$PWD, not the name of the directory containing the binary.