[solved] Gitea 1.15 and up: path not found or permission denied

In Gitea 1.15 the app.example.ini file was changed to comment out most of the values. The assumption was that all values exactly matched the defaults in the source code. However, there are differences, for instance for APP_DATA_PATH. Before Gitea 1.15, app.example.ini contained:

APP_DATA_PATH = data

and the path was relative to the directory from which the Gitea server was running. In Gitea 1.15 up to 1.16, it was commented out:

; APP_DATA_PATH = data

and the path was relative to the work path directory, as provided either via the --work-path argument or the GITEA_WORK_DIR environment variable.

When a distribution such as voidlinux uses app.example.ini as a base for the Gitea package, this change indirectly creates a regression and an upgrade of Gitea fails with errors such as unable to open level db at data/data/queues/common: mkdir data: permission denied. The regression did not show as soon as Gitea 1.15 became available in voidlinux because the package explicitly set APP_DATA_PATH. But this changed when Gitea 1.15.6 was packaged and once the value was commented out, upgrading triggered the problem. This was worked around six month later with the Gitea 1.16.8 package.

The APP_DATA_PATH directory is not the only one, the [log] ROOT_PATH is another example. There is an ongoing effort to improve the situation in Gitea 1.17. With the downside of introducing breaking changes that will have an impact on all Gitea installations because the content of the app.ini file will be interpreted differently. In the case of APP_DATA_PATH, both:

APP_DATA_PATH = data

and:

; APP_DATA_PATH = data

will be interpreted to be relative to the work path directory, as provided either via the --work-path argument or the GITEA_WORK_DIR environment variable. Every Gitea installation using APP_DATA_PATH = data will need to update the value to be an absolute path such as /var/lib/gitea/data so that it keeps pointing to the expected directory.

In order to prepare for the change or ensure the consistency of all path, there fortunately is a very simple solution: always use absolute paths in the app.ini configuration file.