Gitea 1.3.0 fails to start #1310

Closed
opened 2025-11-02 03:56:18 -06:00 by GiteaMirror · 10 comments
Owner

Originally created by @klingtnet on GitHub (Dec 1, 2017).

I just upgrade to gitea 1.3.0 from 1.2.3 and now the service fails to start.
The problem is that the oauth2 plugin seems to ignore the working directory:

$ echo $PWD
/home/gitea/gitea
$ /usr/bin/gitea web --port 10000 --config /home/gitea/gitea/custom/conf/app.ini
# ...
2017/12/01 16:17:18 [...uth/oauth2/oauth2.go:47 Init()] [E] Fail to create dir /usr/bin/data/sessions/oauth2: mkdir /usr/bin/data: permission denied

Gitea was build from source: https://github.com/klingtnet/klingt.net/blob/master/build/gitea/Makefile

Originally created by @klingtnet on GitHub (Dec 1, 2017). I just upgrade to gitea 1.3.0 from 1.2.3 and now the service fails to start. The problem is that the oauth2 plugin seems to ignore the working directory: ``` $ echo $PWD /home/gitea/gitea $ /usr/bin/gitea web --port 10000 --config /home/gitea/gitea/custom/conf/app.ini # ... 2017/12/01 16:17:18 [...uth/oauth2/oauth2.go:47 Init()] [E] Fail to create dir /usr/bin/data/sessions/oauth2: mkdir /usr/bin/data: permission denied ``` Gitea was build from source: https://github.com/klingtnet/klingt.net/blob/master/build/gitea/Makefile
GiteaMirror added the type/bug label 2025-11-02 03:56:18 -06:00
Author
Owner

@klingtnet commented on GitHub (Dec 1, 2017):

This is where gitea crashes: /modules/auth/oauth2/oauth2.go#L45

@klingtnet commented on GitHub (Dec 1, 2017): This is where gitea crashes: [/modules/auth/oauth2/oauth2.go#L45](https://github.com/go-gitea/gitea/blob/master/modules/auth/oauth2/oauth2.go#L45)
Author
Owner

@0rzech commented on GitHub (Dec 3, 2017):

I think the real issue is that by default Gitea wants to create its data directory next to executable file, what seems undesirable more often than not. IMHO, it should default to ${HOME}/gitea on Linux and similar directory on other supported operating systems.

@0rzech commented on GitHub (Dec 3, 2017): I think the real issue is that by default Gitea wants to create its data directory next to executable file, what seems undesirable more often than not. IMHO, it should default to `${HOME}/gitea` on Linux and similar directory on other supported operating systems.
Author
Owner

@0rzech commented on GitHub (Dec 3, 2017):

@klingtnet Could you try to run Gitea the following way?

GITEA_CUSTOM='/home/gitea/gitea/custom' GODEBUG=netdns=go /usr/bin/gitea web --port 10000

It will pick your app.ini and assume anything else is relative to /home/gitea/gitea/custom, AFAIK. This way you won't have to rely on PWD. This is also how it is done in Dockerfile and it's the recommended way to override default custom directory placement.

PS. The GODEBUG=netdns=go is not required, but seems to be a good choice for performance reasons, unless your networking setup is too complicated for Go's net library.
PS. II Please make backups before experimenting with the way you run Gitea. I don't take any responsibility. You know your setup best and if you choose to follow my advices, you do it at your own risk.

@0rzech commented on GitHub (Dec 3, 2017): @klingtnet Could you try to run Gitea the following way? ``` GITEA_CUSTOM='/home/gitea/gitea/custom' GODEBUG=netdns=go /usr/bin/gitea web --port 10000 ``` It will pick your `app.ini` and assume anything else is relative to `/home/gitea/gitea/custom`, AFAIK. This way you won't have to rely on `PWD`. This is also how it is done in [Dockerfile](https://github.com/go-gitea/gitea/blob/master/Dockerfile#L31) and it's the [recommended](https://docs.gitea.io/en-us/customizing-gitea/) way to override default _custom_ directory placement. PS. The `GODEBUG=netdns=go` is not required, but seems to be a good choice for performance reasons, unless your networking setup is too complicated for Go's net library. PS. II Please make backups before experimenting with the way you run Gitea. I don't take any responsibility. You know your setup best and if you choose to follow my advices, you do it at your own risk.
Author
Owner

@klingtnet commented on GitHub (Dec 3, 2017):

@0rzech Thank you for your detailed response.
I tried to set GITEA_CUSTOM—also double checked its value—but the error is still the same, i.e. gitea tries to write to /usr/bin/data.

@klingtnet commented on GitHub (Dec 3, 2017): @0rzech Thank you for your detailed response. I tried to set `GITEA_CUSTOM`—also double checked its value—but the error is still the same, i.e. gitea tries to write to `/usr/bin/data`.
Author
Owner

@0rzech commented on GitHub (Dec 3, 2017):

@klingtnet You're welcome. Could you also post APP_DATA_PATH setting value from your app.ini? I guess it might have been set to /usr/bin/data during installation due to lack of GITEA_CUSTOM environment variable.

@0rzech commented on GitHub (Dec 3, 2017): @klingtnet You're welcome. Could you also post `APP_DATA_PATH` setting value from your `app.ini`? I guess it might have been set to `/usr/bin/data` during installation due to lack of `GITEA_CUSTOM` environment variable.
Author
Owner

@klingtnet commented on GitHub (Dec 3, 2017):

You're a wizard, setting APP_DATA_PATH fixed the problem!
The key did not exist in my app.ini so I added APP_DATA_PATH = /home/gitea/gitea/data to the [server] section.

@klingtnet commented on GitHub (Dec 3, 2017): You're a wizard, setting `APP_DATA_PATH` fixed the problem! The key did not exist in my `app.ini` so I added `APP_DATA_PATH = /home/gitea/gitea/data` to the `[server]` section.
Author
Owner

@klingtnet commented on GitHub (Dec 3, 2017):

I have closed the issue but may considerto set APP_DATA_PATH to pwd if unset?

@klingtnet commented on GitHub (Dec 3, 2017): I have closed the issue but may considerto set `APP_DATA_PATH` to `pwd` if unset?
Author
Owner

@0rzech commented on GitHub (Dec 3, 2017):

@klingtnet If APP_DATA_PATH was absent, then Gitea defaulted to "next-to-binary location".

I think the best way is to run Gitea using the command I presented in my second comment. Once you added the APP_DATA_PATH to your app.ini, it should work fine from now on. This means the conf/app.ini should be in data directory as well, resulting in /home/gitea/data/conf/app.ini.

Also make sure all other paths in your app.ini are set to proper values and all existing data is in right place.

@0rzech commented on GitHub (Dec 3, 2017): @klingtnet If `APP_DATA_PATH` was absent, then Gitea defaulted to "next-to-binary location". I think the best way is to run Gitea using the command I presented in my second comment. Once you added the `APP_DATA_PATH` to your `app.ini`, it should work fine from now on. This means the `conf/app.ini` should be in `data` directory as well, resulting in `/home/gitea/data/conf/app.ini`. Also make sure all other paths in your `app.ini` are set to proper values and all existing data is in right place.
Author
Owner

@klingtnet commented on GitHub (Dec 3, 2017):

@0rzech One note to GODEBUG=netdns=go, it looks like this is already the default behaviour and does not need to be set explicitly: https://golang.org/src/net/net.go

@klingtnet commented on GitHub (Dec 3, 2017): @0rzech One note to `GODEBUG=netdns=go`, it looks like this is already the default behaviour and does not need to be set explicitly: https://golang.org/src/net/net.go
Author
Owner

@0rzech commented on GitHub (Dec 3, 2017):

@klingtnet Yes, you're right. I have even pointed it out myself here.

Btw. it looks like your installation might become a bit messy, because you have /home/gitea/gitea/custom and /home/gitea/data now. GITEA_CUSTOM is better to have the same value as APP_DATA_PATH, IMO. If everything is kept default except for GITEA_CUSTOM itself, then your Gitea directories should look like:

${GITEA_CUSTOM}/avatars
${GITEA_CUSTOM}/conf
${GITEA_CUSTOM}/indexers
${GITEA_CUSTOM}/log
${GITEA_CUSTOM}/sessions

etc.

@0rzech commented on GitHub (Dec 3, 2017): @klingtnet Yes, you're right. I have even pointed it out myself [here](https://github.com/go-gitea/gitea/pull/2927#pullrequestreview-80666199). Btw. it looks like your installation might become a bit messy, because you have `/home/gitea/gitea/custom` and `/home/gitea/data` now. `GITEA_CUSTOM` is better to have the same value as `APP_DATA_PATH`, IMO. If everything is kept default except for `GITEA_CUSTOM` itself, then your Gitea directories should look like: ``` ${GITEA_CUSTOM}/avatars ${GITEA_CUSTOM}/conf ${GITEA_CUSTOM}/indexers ${GITEA_CUSTOM}/log ${GITEA_CUSTOM}/sessions ``` etc.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/gitea#1310