Failed to initialize issue indexer: mkdir data: permission denied in several situations #3339

Closed
opened 2025-11-02 05:09:05 -06:00 by GiteaMirror · 14 comments
Owner

Originally created by @Frickeldave on GitHub (May 15, 2019).

  • Gitea version (or commit ref): 1.7.2 & 1.8.0
  • Git version: 2.2.0
  • Operating system: Alpine 3.9 within Docker
  • Database (use [x]):
    • PostgreSQL
    • MySQL
    • MSSQL
    • SQLite
  • Can you reproduce the bug at https://try.gitea.io:
    • Yes (provide example URL)
    • No
    • Not relevant
  • Log gist:

Description

i created my own docker image, based on alpine 3.9. I use gitea 1.7.2 currently. The docker-host is a current CentOS.
I have the issue, that it is not possible to update something in a repo and to do merges with the webinterface (i think they belong together). When i try to do that, i get the following messages:

Edit something in the webinterface and commit:
UpdateLocalCopyBranch [branch: master]: git clone master: mkdir data: permission denied (Message appera in web ui)

Try to merge something within the webinterface
[…routers/repo/pull.go:589 MergePullRequest()] [E] Merge: Failed to create dir data/tmp/local-repo/merge-302991419.git: mkdir data: permission denied (Message appear in logfile)

The environment
In the docker image i created a user “appuser” with UID and GID 140000. The gitea binaries are stored in /home/appuser/app, the configuration files are stored in /home/appuser/data. Of course, the appuser has access to both directories. I have a startscript (start.sh) as entrypoint defined. In this startscript i set all needed variables:

_export USER=$(whoami)
export USERNAME=$(whoami)
export GITEA_CUSTOM=/home/appuser/data/custom
export GITEA_WORK_DIR=/home/appuser/data_

I start gitea with /home/appuser/app/gitea -c /home/appuser/data/gitea.ini within the start.sh script.

No i tried to update to gitea 1.8.0 before opening this ticket. Now the server isn't starting anymore within exact the same docker image. The output of the console is

/ $ /home/appuser/app/gitea -c /home/appuser/data/gitea.ini
2019/05/15 14:03:35 [T] AppPath: /home/appuser/app/gitea
2019/05/15 14:03:35 [T] AppWorkPath: /home/appuser/app
2019/05/15 14:03:35 [T] Custom path: /home/appuser/data/custom
2019/05/15 14:03:35 [T] Log path: /home/appuser/data/log
/ $

In the logfile i have the following message:
2019/05/15 14:03:35 [I] Log Mode: File(Debug)
2019/05/15 14:03:35 [I] XORM Log Mode: File(Debug)
2019/05/15 14:03:35 [I] Cache Service Enabled
2019/05/15 14:03:35 [I] Session Service Enabled
2019/05/15 14:03:35 [I] Mail Service Enabled
2019/05/15 14:03:35 [I] Beginning ORM engine initialization.
2019/05/15 14:03:35 [I] ORM engine initialization attempt #1/10...
2019/05/15 14:03:35 [I] ORM engine initialization successful!
2019/05/15 14:03:35 [I] Git Version: 2.20.1
2019/05/15 14:03:35 [...itea/routers/init.go:95 GlobalInit()] [E] Failed to initialize issue indexer: mkdir data: permission denied

In gitea.ini the "APP" and "ROOT" pathes are specified as followed:

STATIC_ROOT_PATH = /home/appuser/app
APP_DATA_PATH = /home/appuser/data

From my point of view the cause of these issues is the same.
I also found issues #4672 and #6398 which are probably related, bot are closed and reference to #6367 which is a complete other topic (from my point of view, possibly i am wrong).

Would be cool to get help here...

Thanks in advance

Dave

Originally created by @Frickeldave on GitHub (May 15, 2019). - Gitea version (or commit ref): 1.7.2 & 1.8.0 - Git version: 2.2.0 - Operating system: Alpine 3.9 within Docker - Database (use `[x]`): - [ ] PostgreSQL - [x] MySQL - [ ] MSSQL - [ ] SQLite - Can you reproduce the bug at https://try.gitea.io: - [ ] Yes (provide example URL) - [ ] No - [x] Not relevant - Log gist: ## Description i created my own docker image, based on alpine 3.9. I use gitea 1.7.2 currently. The docker-host is a current CentOS. I have the issue, that it is not possible to update something in a repo and to do merges with the webinterface (i think they belong together). When i try to do that, i get the following messages: Edit something in the webinterface and commit: _UpdateLocalCopyBranch [branch: master]: git clone master: mkdir data: permission denied_ (Message appera in web ui) Try to merge something within the webinterface _[…routers/repo/pull.go:589 MergePullRequest()] [E] Merge: Failed to create dir data/tmp/local-repo/merge-302991419.git: mkdir data: permission denied_ (Message appear in logfile) The environment In the docker image i created a user “appuser” with UID and GID 140000. The gitea binaries are stored in /home/appuser/app, the configuration files are stored in _/home/appuser/data_. Of course, the appuser has access to both directories. I have a startscript (start.sh) as entrypoint defined. In this startscript i set all needed variables: _export USER=$(whoami) export USERNAME=$(whoami) export GITEA_CUSTOM=/home/appuser/data/custom export GITEA_WORK_DIR=/home/appuser/data_ I start gitea with _/home/appuser/app/gitea -c /home/appuser/data/gitea.ini_ within the start.sh script. No i tried to update to gitea 1.8.0 before opening this ticket. Now the server isn't starting anymore within exact the same docker image. The output of the console is _/ $ /home/appuser/app/gitea -c /home/appuser/data/gitea.ini 2019/05/15 14:03:35 [T] AppPath: /home/appuser/app/gitea 2019/05/15 14:03:35 [T] AppWorkPath: /home/appuser/app 2019/05/15 14:03:35 [T] Custom path: /home/appuser/data/custom 2019/05/15 14:03:35 [T] Log path: /home/appuser/data/log / $_ In the logfile i have the following message: _2019/05/15 14:03:35 [I] Log Mode: File(Debug) 2019/05/15 14:03:35 [I] XORM Log Mode: File(Debug) 2019/05/15 14:03:35 [I] Cache Service Enabled 2019/05/15 14:03:35 [I] Session Service Enabled 2019/05/15 14:03:35 [I] Mail Service Enabled 2019/05/15 14:03:35 [I] Beginning ORM engine initialization. 2019/05/15 14:03:35 [I] ORM engine initialization attempt #1/10... 2019/05/15 14:03:35 [I] ORM engine initialization successful! 2019/05/15 14:03:35 [I] Git Version: 2.20.1 2019/05/15 14:03:35 [...itea/routers/init.go:95 GlobalInit()] [E] Failed to initialize issue indexer: mkdir data: permission denied_ In gitea.ini the "APP" and "ROOT" pathes are specified as followed: STATIC_ROOT_PATH = /home/appuser/app APP_DATA_PATH = /home/appuser/data From my point of view the cause of these issues is the same. I also found issues #4672 and #6398 which are probably related, bot are closed and reference to #6367 which is a complete other topic (from my point of view, possibly i am wrong). Would be cool to get help here... Thanks in advance Dave
GiteaMirror added the issue/needs-feedback label 2025-11-02 05:09:05 -06:00
Author
Owner

@lunny commented on GitHub (May 17, 2019):

Merge pull request should be a known issue.

@lunny commented on GitHub (May 17, 2019): Merge pull request should be a known issue.
Author
Owner

@Frickeldave commented on GitHub (May 19, 2019):

But as described before, it's not only an issue with pull requests, also with editing in web and with version 1.8.0 during startup...

@Frickeldave commented on GitHub (May 19, 2019): But as described before, it's not only an issue with pull requests, also with editing in web and with version 1.8.0 during startup...
Author
Owner

@lunny commented on GitHub (May 20, 2019):

@Frickeldave I think you should check your filesystem permission since the log said permission denied.

@lunny commented on GitHub (May 20, 2019): @Frickeldave I think you should check your filesystem permission since the log said `permission denied`.
Author
Owner

@Frickeldave commented on GitHub (May 20, 2019):

Hi,

that was the first thing i have done. But i think the permissions are not the problem. The path /home/appuser/app and /home/appuser/data is fully writable for the user.

drwxr-sr-x 1 appuser appuser 26 May 17 06:58 .
drwxr-xr-x 1 root root 21 Feb 22 07:57 ..
-rw------- 1 appuser appuser 90 May 20 07:44 .ash_history
-rw-r--r-- 1 appuser appuser 150 May 15 15:29 .bashrc
drwxr-sr-x 1 appuser appuser 16 May 15 15:28 app
drwxr-sr-x 11 appuser appuser 269 May 17 06:49 data

Is it possile, that gitea tries to write to another path?

Regards

Dave

@Frickeldave commented on GitHub (May 20, 2019): Hi, that was the first thing i have done. But i think the permissions are not the problem. The path /home/appuser/app and /home/appuser/data is fully writable for the user. _drwxr-sr-x 1 appuser appuser 26 May 17 06:58 . drwxr-xr-x 1 root root 21 Feb 22 07:57 .. -rw------- 1 appuser appuser 90 May 20 07:44 .ash_history -rw-r--r-- 1 appuser appuser 150 May 15 15:29 .bashrc drwxr-sr-x 1 appuser appuser 16 May 15 15:28 app drwxr-sr-x 11 appuser appuser 269 May 17 06:49 data_ Is it possile, that gitea tries to write to another path? Regards Dave
Author
Owner

@Frickeldave commented on GitHub (May 22, 2019):

Hi,

any ideas regarding that issue? Any more feedback needed?

Regards

Dave

@Frickeldave commented on GitHub (May 22, 2019): Hi, any ideas regarding that issue? Any more feedback needed? Regards Dave
Author
Owner

@zeripath commented on GitHub (May 22, 2019):

The issue indexer path is determined here:

6eb53ac570/modules/setting/indexer.go (L45)

AppDataPath is determined here:

6eb53ac570/modules/setting/setting.go (L615)

And AppWorkPath is either:

  • DIRECTORY_OF_GITEA_BINARY
  • $GITEA_WORK_DIR

In 1.9 you will be able to set this using the --work-dir option.

Looking at the information you've provided it looks like you need to set GITEA_WORK_DIR=/home/appuser/data

I suggest you shadow Gitea with a script that sets these for you.

@zeripath commented on GitHub (May 22, 2019): The issue indexer path is determined here: https://github.com/go-gitea/gitea/blob/6eb53ac570ab9af51fc9cbd79f1db782edce57e0/modules/setting/indexer.go#L45 AppDataPath is determined here: https://github.com/go-gitea/gitea/blob/6eb53ac570ab9af51fc9cbd79f1db782edce57e0/modules/setting/setting.go#L615 And AppWorkPath is either: * DIRECTORY_OF_GITEA_BINARY * $GITEA_WORK_DIR In 1.9 you will be able to set this using the --work-dir option. Looking at the information you've provided it looks like you need to set GITEA_WORK_DIR=/home/appuser/data I suggest you shadow Gitea with a script that sets these for you.
Author
Owner

@Frickeldave commented on GitHub (May 22, 2019):

Hi,

thank you very much. I already have a wrapper script. In my inital post this is already described:

I have a startscript (start.sh) as entrypoint defined. In this startscript i set all needed variables:

_
export USER=$(whoami)
export USERNAME=$(whoami)
export GITEA_CUSTOM=/home/appuser/data/custom
export GITEA_WORK_DIR=/home/appuser/data
_

I start gitea with /home/appuser/app/gitea -c /home/appuser/data/gitea.ini within the start.sh script.

Regards

Dave

@Frickeldave commented on GitHub (May 22, 2019): Hi, thank you very much. I already have a wrapper script. In my inital post this is already described: I have a startscript (start.sh) as entrypoint defined. In this startscript i set all needed variables: _ export USER=$(whoami) export USERNAME=$(whoami) export GITEA_CUSTOM=/home/appuser/data/custom export GITEA_WORK_DIR=/home/appuser/data _ I start gitea with /home/appuser/app/gitea -c /home/appuser/data/gitea.ini within the start.sh script. Regards Dave
Author
Owner

@zeripath commented on GitHub (May 22, 2019):

I don't think your Gitea work dir export is working properly 2019/05/15 14:03:35 [T] AppWorkPath: /home/appuser/app

@zeripath commented on GitHub (May 22, 2019): I don't think your Gitea work dir export is working properly `2019/05/15 14:03:35 [T] AppWorkPath: /home/appuser/app`
Author
Owner

@zeripath commented on GitHub (May 22, 2019):

There's another place things get written to (!) $HOME/gitea-repositories but I can't remember off the top of my head which config that corresponds to.

@zeripath commented on GitHub (May 22, 2019): There's another place things get written to (!) $HOME/gitea-repositories but I can't remember off the top of my head which config that corresponds to.
Author
Owner

@Frickeldave commented on GitHub (May 22, 2019):

Possibly. Here is a print from my console output:

_
/ $ echo "" > /home/appuser/data/log/gitea.log
/ $ cat /home/appuser/data/log/gitea.log

/ $ echo $GITEA_WORK_DIR
/home/appuser/data
/ $ /home/appuser/app/gitea web -c /home/appuser/data/gitea.ini
2019/05/22 12:23:36 [T] AppPath: /home/appuser/app/gitea
2019/05/22 12:23:36 [T] AppWorkPath: /home/appuser/data
2019/05/22 12:23:36 [T] Custom path: /home/appuser/data/custom
2019/05/22 12:23:36 [T] Log path: /home/appuser/data/log
/ $ cat /home/appuser/data/log/gitea.log

2019/05/22 12:23:36 [I] Log Mode: File(Info)
2019/05/22 12:23:36 [I] XORM Log Mode: File(Info)
2019/05/22 12:23:36 [I] Cache Service Enabled
2019/05/22 12:23:36 [I] Session Service Enabled
2019/05/22 12:23:36 [I] Beginning ORM engine initialization.
2019/05/22 12:23:36 [I] ORM engine initialization attempt #1/10...
2019/05/22 12:23:36 [I] ORM engine initialization successful!
2019/05/22 12:23:36 [I] Git Version: 2.20.1
2019/05/22 12:23:36 [...itea/routers/init.go:95 GlobalInit()] [E] Failed to initialize issue indexer: mkdir indexers: permission denied
_

As you can see, in the current console session, GITEA_WORK_DIR is set properly. Any other thing i can check?

Attached you will find my gitea.ini file.

Regards

Dave

gitea.ini.zip

@Frickeldave commented on GitHub (May 22, 2019): Possibly. Here is a print from my console output: _ / $ echo "" > /home/appuser/data/log/gitea.log / $ cat /home/appuser/data/log/gitea.log / $ echo $GITEA_WORK_DIR /home/appuser/data / $ /home/appuser/app/gitea web -c /home/appuser/data/gitea.ini 2019/05/22 12:23:36 [T] AppPath: /home/appuser/app/gitea 2019/05/22 12:23:36 [T] AppWorkPath: /home/appuser/data 2019/05/22 12:23:36 [T] Custom path: /home/appuser/data/custom 2019/05/22 12:23:36 [T] Log path: /home/appuser/data/log / $ cat /home/appuser/data/log/gitea.log 2019/05/22 12:23:36 [I] Log Mode: File(Info) 2019/05/22 12:23:36 [I] XORM Log Mode: File(Info) 2019/05/22 12:23:36 [I] Cache Service Enabled 2019/05/22 12:23:36 [I] Session Service Enabled 2019/05/22 12:23:36 [I] Beginning ORM engine initialization. 2019/05/22 12:23:36 [I] ORM engine initialization attempt #1/10... 2019/05/22 12:23:36 [I] ORM engine initialization successful! 2019/05/22 12:23:36 [I] Git Version: 2.20.1 2019/05/22 12:23:36 [...itea/routers/init.go:95 GlobalInit()] [E] Failed to initialize issue indexer: mkdir indexers: permission denied _ As you can see, in the current console session, GITEA_WORK_DIR is set properly. Any other thing i can check? Attached you will find my gitea.ini file. Regards Dave [gitea.ini.zip](https://github.com/go-gitea/gitea/files/3207322/gitea.ini.zip)
Author
Owner

@zeripath commented on GitHub (May 22, 2019):

It looks like you've just copied the whole of app.ini.sample as your app.ini... That's unnecessary and a very good way of ending up over-configuring things and perhaps even breaking things.

You should only copy what you need. For example, the log section is not meant to copied over exactly the way you have done - did you read it? I'm also concerned that you say you're using 1.7.2 (or maybe 1.8.0) but that app.ini.sample is the 1.9 sample. (You're definitely not running 1.9 I can tell from the logging.) I would seriously recommend paring down your app.ini so that it represents what you need to configure and only what you need to configure.

Further are you telling me that you're ending up with different configuration between starting gitea on the console and starting it through your start.sh script? If so the problem lies in your start.sh script. Is it possible that your options are being overridden somewhere else? On the admin pages of gitea you should be able to check where it thinks it is looking for things. In particular it will say if GITEA_WORK_DIR is set and/or GITEA_CUSTOM.

You really should also upgrade your Gitea to at least 1.8.1.

@zeripath commented on GitHub (May 22, 2019): It looks like you've just copied the whole of app.ini.sample as your app.ini... That's unnecessary and a very good way of ending up over-configuring things and perhaps even breaking things. You should only copy what you need. For example, the log section is not meant to copied over exactly the way you have done - did you read it? I'm also concerned that you say you're using 1.7.2 (or maybe 1.8.0) but that app.ini.sample is the 1.9 sample. (You're definitely not running 1.9 I can tell from the logging.) I would seriously recommend paring down your app.ini so that it represents what you need to configure and only what you need to configure. Further are you telling me that you're ending up with different configuration between starting gitea on the console and starting it through your start.sh script? If so the problem lies in your start.sh script. Is it possible that your options are being overridden somewhere else? On the admin pages of gitea you should be able to check where it thinks it is looking for things. In particular it will say if GITEA_WORK_DIR is set and/or GITEA_CUSTOM. You really should also upgrade your Gitea to at least 1.8.1.
Author
Owner

@Frickeldave commented on GitHub (May 22, 2019):

Thank you very much for the time you invest.
Currently in 1.8.0 i have the situtation, that gitea isn't starting, therefore i cannot look into the admin page. It just write out the 4 lines at the console i have posted before. In the version 1.7.2 gitea is starting with the same configuration file (1.7.2 is our prod system, 1.8.0 my dev system).
Currently i ran gitea from an interactive console just for testing (and to exclude every issue that should come from the start.sh script). I execute the 4 export command and then run gitea as shown before.
Regarding the app.ini version: I will compare with the 1.8.0 version, and let you know the results here.

@Frickeldave commented on GitHub (May 22, 2019): Thank you very much for the time you invest. Currently in 1.8.0 i have the situtation, that gitea isn't starting, therefore i cannot look into the admin page. It just write out the 4 lines at the console i have posted before. In the version 1.7.2 gitea is starting with the same configuration file (1.7.2 is our prod system, 1.8.0 my dev system). Currently i ran gitea from an interactive console just for testing (and to exclude every issue that should come from the start.sh script). I execute the 4 export command and then run gitea as shown before. Regarding the app.ini version: I will compare with the 1.8.0 version, and let you know the results here.
Author
Owner

@Frickeldave commented on GitHub (Jun 4, 2019):

Fixed the error regarding the failed start of gitea 1.8.0. The default value for ISSUE_INDEXER_PATH and ISSUE_INDEXER_QUEUE_DIR are set to "indexers/issue.bleve / indexers/issue.queue". This works in 1.7.2 but not in 1.8.0. I changed the pathes to an absolute path (/home/appuser/data/indexers/.... )and now the server starts. At next i will try to find out why its not possible to edit files within web editor or do merges within web editor.

@Frickeldave commented on GitHub (Jun 4, 2019): Fixed the error regarding the failed start of gitea 1.8.0. The default value for ISSUE_INDEXER_PATH and ISSUE_INDEXER_QUEUE_DIR are set to "indexers/issue.bleve / indexers/issue.queue". This works in 1.7.2 but not in 1.8.0. I changed the pathes to an absolute path (/home/appuser/data/indexers/.... )and now the server starts. At next i will try to find out why its not possible to edit files within web editor or do merges within web editor.
Author
Owner

@Frickeldave commented on GitHub (Jun 13, 2019):

WIth the previous describes change also the web-based editor as well as pull requests are working now. Closing ticket.

@Frickeldave commented on GitHub (Jun 13, 2019): WIth the previous describes change also the web-based editor as well as pull requests are working now. Closing ticket.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/gitea#3339