A gentle introduction to the gitea doctor - Blog

Tue Jun 14, 2022 by dachary


This is a companion discussion topic for the original entry at https://blog.gitea.io/2022/06/a-gentle-introduction-to-the-gitea-doctor/

Thanks for the introduction to gitea doctor. I was going to try it out on my self-hosted Docker instance of Gitea using the --all flag, but it stopped after the first check.

m@f /etc/docker/gitea $ docker compose exec gitea gitea doctor --all
[1] Check paths and basic configuration
m@f /etc/docker/gitea $ 

Same behavior applies, when I do this inside the container (docker compose exec gitea bash …). I even tried to push it into the right direction by passing these environment variables:

bash-5.1# HOME=/data/gitea GITEA_WORK_DIR=/data/gitea gitea -c /data/gitea/conf/app.ini doctor --all                                                                                          
[1] Check paths and basic configuration
bash-5.1#

This is on Gitea 1.16.8 installed from image: gitea/gitea:1.16.

Can you explain what went wrong?

1 Like

You need more flags when not using rootless:

$ docker exec --user git --workdir=/tmp gitea gitea doctor --all

See below for details.

Gave it a try tonight. Gitea is running fine. It is installed on a VM. This is version 1.16.5

$ gitea doctor -c /etc/gitea/app.ini
[1] Check paths and basic configuration
 - [I] Configuration File Path:    "/etc/gitea/app.ini"
[git@projects ~]$ echo $?
1
[git@projects ~]$ gitea doctor -c /etc/gitea/app.ini 
[1] Check paths and basic configuration
 - [I] Configuration File Path:    "/etc/gitea/app.ini"
 - [I] Repository Root Path:       "/var/lib/gitea/data/gitea-repositories"
 - [I] Data Root Path:             "/usr/local/bin/data"
 - [E]     Is REQUIRED but is not accessible. ERROR: stat /usr/local/bin/data: no such file or directory
 - [I] Custom File Root Path:      "/usr/local/bin/custom"
 - [W]     NOTICE: is not accessible (Error: stat /usr/local/bin/custom: no such file or directory)
 - [I] Work directory:             "/usr/local/bin"
 - [I] Log Root Path:              "/var/lib/gitea/log"
 - [C] Please check your configuration files and try again.
FAIL

Everything is under /var/lib/gitea and owned by gitea. /usr/local/bin/custom is not referenced by the config file. Do you know why it’s trying to look there?

Assuming you are running Gitea from binary with systemd, you need to specify --work-path:

$ gitea doctor --work-path /var/lib/gitea -c /etc/gitea/app.ini

See below for details:

Thanks for the tip! Seems all is well.

$ gitea doctor --work-path /var/lib/gitea -c /etc/gitea/app.ini
[1] Check paths and basic configuration
 - [I] Configuration File Path:    "/etc/gitea/app.ini"
 - [I] Repository Root Path:       "/var/lib/gitea/data/gitea-repositories"
 - [I] Data Root Path:             "/var/lib/gitea/data"
 - [I] Custom File Root Path:      "/usr/local/bin/custom"
 - [W]     NOTICE: is not accessible (Error: stat /usr/local/bin/custom: no such file or directory)
 - [I] Work directory:             "/var/lib/gitea"
 - [I] Log Root Path:              "/var/lib/gitea/log"
OK
[2] Check Database Version
OK
[3] Check if user with wrong type exist
OK
[4] Check if OpenSSH authorized_keys file is up-to-date
OK
1 Like

One note that I would like to make here.
So I follow the instructions/guide for the doctor on my gitea server (By the way thank you very much for the post. It was very helpful).
When I run it last Friday, I noticed some warnings. They were the only warnings under the check of the hook files. To give an example of the nature of the warning here is a sample

[8] Check if hook files are up-to-date and executable
 - [W] new hook file /var/lib/gitea/repositories/user/my_super_repo.git/hooks/pre-receive.d/gitea is out of date

There were so many of them and as I have already mentioned they were the only warning that I got from running gitea doctor --all
So I thought to run the obvious command gitea doctor --run hooks --fix which run successfully and to double check that I followed up with the command gitea doctor --run hooks which came back with 0 warnings or errors.
By doing the above it broke our Gitea Server. No one could post any commits by any means (ssh or web UI). So to fix the “fix” from the doctor I run from the “Administrators” gui the option to “Re-sync the web-hooks”

To be honest I run all of the above on a perfectly running Server. Just being OCD, I wanted to have ( I believed) a free from warnings(eliminate them) server and a clean report.

The guide was perfect, but I would like to see a few exceptions or what should be avoided or ignored in any level of report/log (Warnings, Information, Errors).

Kind regards

1 Like

It looks like a bug in the doctor. What Gitea version are you running?

I 'm running 1.16.5 with Go 1.18

In order to figure out the problem, it would help to see the logs and the error message that was displayed. Can you please copy/paste them?