gitea: Gitea's path system quirk and bug

Description

In history, Gitea’s binary was designed to use the binary directory as working directory, it tries to create/use its “data”/“custom” directories in the binary path. For example: running /usr/local/bin/gitea makes Gitea try to use /usr/local/bin/custom directory, which is improper/wrong, and it causes a lot of problems.

POSIX users please use https://github.com/go-gitea/gitea/tree/main/contrib/fhs-compliant-script , do not put Gitea binary into /usr/loca/bin directory – unless you are 100% sure about the details.

“custom” bug

A feedback from discord


Update gitea from 1.15.6 to 1.15.7 (and then 1.19.1):

Failed to include custom: open /usr/local/bin/custom/conf/app.ini: permission denied
2023/04/20 06:06:09 cmd/dump.go:150:fatal() [F] Failed to include custom: open /usr/local/bin/custom/conf/app.ini: permission denied

I’m using the script in contrib/upgrade.sh and as far as I’m concerned I have never used this “custom” folder, why is it needed? (I am using sqlite3 as well)

I don’t get why it’s trying to read/write in that particular folder and not from /var/lib/gitea/custom

About this issue

  • Original URL
  • State: closed
  • Created a year ago
  • Comments: 28 (13 by maintainers)

Commits related to this issue

Most upvoted comments

I was able to solve this issue by just adding the proper backupopts:

 giteauser=gitea backupopts="-c /etc/gitea/app.ini -C /var/lib/gitea/custom" ./gitea_upgrade.sh -v 1.15.7

No offense, but my impression is that the path handling code in Gitea overall is pretty fragile and buggy…

That’s true … 🤣 and it’s quite complex that’s why there are many issues which are difficult to fix before refactoring.

For me, I have done my best to optimize it, since it is really complex, I won’t say my code is bug-free, while I think it is the right way and if there is any bug in my code, I will always fix them in the first time (as usual).

#25330 stores the WORK_PATH

I see, the document is not clear either. I think zeripath has explained about this problem with backgrounds https://github.com/go-gitea/gitea/issues/24222#issuecomment-1535246772

If #25330 could be merged, I think I could also improve the documents about the “work path” topic, and at that time, we do not need to play with the “path tricks” any more.

Thank you very much for helping investigating the problem 🙏 , I guess we are near to the complete solution now. 😄