Gitea: Change behavior for GITEA_WORK_DIR

Created on 31 Mar 2017  路  6Comments  路  Source: go-gitea/gitea

Background

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.

Change behavior for GITEA_WORK_DIR

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.

Setup

  • Gitea: 1.1.0
kinbug

Most helpful comment

I agree the behavior should be for the default to be $PWD, not the name of the directory containing the binary.

All 6 comments

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

Was this page helpful?
0 / 5 - 0 ratings

Related issues

jonasfranz picture jonasfranz  路  3Comments

kolargol picture kolargol  路  3Comments

jorise7 picture jorise7  路  3Comments

adpande picture adpande  路  3Comments

lunny picture lunny  路  3Comments