Gitea produces superfluous file / folder permission errors when installed through snap #11773

Closed
opened 2025-11-02 09:47:19 -06:00 by GiteaMirror · 4 comments
Owner

Originally created by @TheFriendlyCoder on GitHub (Oct 3, 2023).

Description

Installing Gitea on Ubuntu Server using snap, it would appear as though the gitea service is unable to manipulate files in any folder on the system other than those in the /var/snap/gitea sub-dir. For example, I have a completely working configuration on my Ubuntu server using all default options. If I change this one line in the app.ini file:

Before:

[database]
/var/snap/gitea/common/data

After:

[database]
/data/gitea/data

and try running the app by doing something like:

su -c "gitea web --port=3005" git

I get a ORM engine initialization attempt #1/10 failed. Error: failed to connect to database: Failed to create directories: mkdir /data: permission denied error.

Even if the /data/gitea/data folder / tree is created in advance, and the git user is set up as the owner, etc. the problem still persists:

mkdir -p /data/gitea/data
chmod -R 0755 /data
chown -R git:git /data

The most notable / strange part of this error is that gitea is complaining about the root folder /data rather than the full path /data/gitea/data, which suggests to me the app is trying to manipulate the root folder of the path for some strange reason, even though - as I've described above - it should have no reason to do so.

Gitea Version

Gitea version 1.20.5 built with GNU Make 4.3, go1.21.1 : bindata, sqlite, sqlite_unlock_notify, pam, cert

Can you reproduce the bug on the Gitea demo site?

No

Log Gist

No response

Screenshots

No response

Git Version

git version 2.34.1

Operating System

Ubuntu 22.04.3 LTS

How are you running Gitea?

I have tried running the app directly from the command line as the current user (gitea ....), indirectly from the command line as a specific user (ie: su -c "gitea...." git), and indirectly as a systemd service (ie: systemctl start gitea). In all cases the service runs fine with the default app.ini configuration, but changing ANY of the data paths (ie: APP_DATA_PATH, repository->ROOT, etc. etc.) results in the same error being thrown.

Database

SQLite

Originally created by @TheFriendlyCoder on GitHub (Oct 3, 2023). ### Description Installing Gitea on Ubuntu Server using snap, it would appear as though the gitea service is unable to manipulate files in any folder on the system other than those in the /var/snap/gitea sub-dir. For example, I have a completely working configuration on my Ubuntu server using all default options. If I change this one line in the app.ini file: Before: ``` [database] /var/snap/gitea/common/data ``` After: ``` [database] /data/gitea/data ``` and try running the app by doing something like: `su -c "gitea web --port=3005" git` I get a **ORM engine initialization attempt #1/10 failed. Error: failed to connect to database: Failed to create directories: mkdir /data: permission denied** error. Even if the /data/gitea/data folder / tree is created in advance, and the `git` user is set up as the owner, etc. the problem still persists: ``` mkdir -p /data/gitea/data chmod -R 0755 /data chown -R git:git /data ``` The most notable / strange part of this error is that gitea is complaining about the root folder /data rather than the full path /data/gitea/data, which suggests to me the app is trying to manipulate the root folder of the path for some strange reason, even though - as I've described above - it should have no reason to do so. ### Gitea Version Gitea version 1.20.5 built with GNU Make 4.3, go1.21.1 : bindata, sqlite, sqlite_unlock_notify, pam, cert ### Can you reproduce the bug on the Gitea demo site? No ### Log Gist _No response_ ### Screenshots _No response_ ### Git Version git version 2.34.1 ### Operating System Ubuntu 22.04.3 LTS ### How are you running Gitea? I have tried running the app directly from the command line as the current user (`gitea ....`), indirectly from the command line as a specific user (ie: `su -c "gitea...." git`), and indirectly as a systemd service (ie: `systemctl start gitea`). In all cases the service runs fine with the default app.ini configuration, but changing ANY of the data paths (ie: APP_DATA_PATH, repository->ROOT, etc. etc.) results in the same error being thrown. ### Database SQLite
GiteaMirror added the type/bug label 2025-11-02 09:47:19 -06:00
Author
Owner

@TheFriendlyCoder commented on GitHub (Oct 4, 2023):

I believe a similar problem with the .ssh config folder was also report here: https://github.com/go-gitea/gitea/issues/25102

@TheFriendlyCoder commented on GitHub (Oct 4, 2023): I believe a similar problem with the .ssh config folder was also report here: https://github.com/go-gitea/gitea/issues/25102
Author
Owner

@techknowlogick commented on GitHub (Oct 4, 2023):

I believe this is intentional on behalf of snap due to their security model, but I'll keep this open in case someone else can provide more insight.

@techknowlogick commented on GitHub (Oct 4, 2023): I believe this is intentional on behalf of snap due to their security model, but I'll keep this open in case someone else can provide more insight.
Author
Owner

@TheFriendlyCoder commented on GitHub (Oct 4, 2023):

If that is the case it may be worth mentioning this somewhere in the docs. I spent hours debugging permission problems with gitea this past week, and all that wasted time could have been avoided with a small footnote somewhere in your docs. :p

@TheFriendlyCoder commented on GitHub (Oct 4, 2023): If that is the case it may be worth mentioning this somewhere in the docs. I spent hours debugging permission problems with gitea this past week, and all that wasted time could have been avoided with a small footnote somewhere in your docs. :p
Author
Owner

@lng2020 commented on GitHub (Oct 23, 2023):

The doc is updated in 1.21rc. So I am closing two of your three issues with the snap package and leaving that dump cmd issue(The dump command indeed has several bugs). Feel free to reopen if you have other concerns.

@lng2020 commented on GitHub (Oct 23, 2023): The doc is updated in 1.21rc. So I am closing two of your three issues with the `snap` package and leaving that `dump` cmd issue(The `dump` command indeed has several bugs). Feel free to reopen if you have other concerns.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/gitea#11773