# A gentle introduction to the gitea doctor - Blog

**URL:** <https://forum.gitea.com/t/a-gentle-introduction-to-the-gitea-doctor-blog/5358>\
**Category:** Announcements\
**Created:** [June 15, 2022, 10:00am UTC](https://forum.gitea.com/t/a-gentle-introduction-to-the-gitea-doctor-blog/5358 "2022-06-15T10:00:23Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![gitea](https://avatars.discourse-cdn.com/v4/letter/g/46a35a/32.png) [@gitea](https://forum.gitea.com/u/gitea)\
**Post date:** [June 15, 2022, 10:00am UTC](https://forum.gitea.com/t/a-gentle-introduction-to-the-gitea-doctor-blog/5358/1 "2022-06-15T10:00:23Z")

</div>

_Tue Jun 14, 2022_ by **[dachary](https://gitea.com/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/](https://blog.gitea.io/2022/06/a-gentle-introduction-to-the-gitea-doctor/)

---

<div class="post-metadata">

**Author:** ![mcnesium](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.gitea.com/mcnesium/32/241_2.png) [@mcnesium](https://forum.gitea.com/u/mcnesium)\
**Post date:** [June 15, 2022, 12:21pm UTC](https://forum.gitea.com/t/a-gentle-introduction-to-the-gitea-doctor-blog/5358/2 "2022-06-15T12:21:36Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![gitea](https://avatars.discourse-cdn.com/v4/letter/g/46a35a/32.png) [@gitea](https://forum.gitea.com/u/gitea)\
**Post date:** [June 15, 2022, 12:21pm UTC](https://forum.gitea.com/t/a-gentle-introduction-to-the-gitea-doctor-blog/5358/3 "2022-06-15T12:21:36Z")

</div>



---

<div class="post-metadata">

**Author:** ![dachary](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.gitea.com/dachary/32/4990_2.png) [@dachary](https://forum.gitea.com/u/dachary)\
**Post date:** [June 15, 2022, 2:31pm UTC](https://forum.gitea.com/t/a-gentle-introduction-to-the-gitea-doctor-blog/5358/4 "2022-06-15T14:31:04Z")

</div>

You need more flags when not using rootless:

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

```

See below for details.

> **[Hostea Gitea Hosting & Clinic (@hostea@mastodon.online)](https://mastodon.online/@hostea/108481959394012947)**
>
> \#Hostea tip: running \`gitea doctor\` on a docker \`gitea/gitea:1.16.8\` installation can be done with:
> 
> docker exec --user git --workdir=/tmp gitea gitea doctor --all
> 
> The --user git is because it otherwise runs as root and is not setup properly to run...

---

<div class="post-metadata">

**Author:** ![jkugler](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.gitea.com/jkugler/32/5058_2.png) [@jkugler](https://forum.gitea.com/u/jkugler)\
**Post date:** [June 17, 2022, 3:57am UTC](https://forum.gitea.com/t/a-gentle-introduction-to-the-gitea-doctor-blog/5358/5 "2022-06-17T03:57:21Z")

</div>

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

```auto
$ 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?

---

<div class="post-metadata">

**Author:** ![dachary](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.gitea.com/dachary/32/4990_2.png) [@dachary](https://forum.gitea.com/u/dachary)\
**Post date:** [June 17, 2022, 7:12pm UTC](https://forum.gitea.com/t/a-gentle-introduction-to-the-gitea-doctor-blog/5358/6 "2022-06-17T19:12:50Z")

</div>

Assuming you are running Gitea [from binary with systemd](https://docs.gitea.io/en-us/linux-service/), you need to specify `--work-path`:

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

```

See below for details:

> **[Hostea Gitea Hosting & Clinic (@hostea@mastodon.online)](https://mastodon.online/@hostea/108494389067708521)**
>
> \#Hostea tip: when Gitea is installed from from binary, you need to run it with --work-path in addition to -c to make the doctor work:
> 
> gitea doctor --work-path /var/lib/gitea -c /etc/gitea/app.ini
> 
> It is not enough to provide @Gitea with the...

---

<div class="post-metadata">

**Author:** ![jkugler](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.gitea.com/jkugler/32/5058_2.png) [@jkugler](https://forum.gitea.com/u/jkugler)\
**Post date:** [July 15, 2022, 9:04pm UTC](https://forum.gitea.com/t/a-gentle-introduction-to-the-gitea-doctor-blog/5358/7 "2022-07-15T21:04:38Z")

</div>

Thanks for the tip! Seems all is well.

```auto
$ 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

```

---

<div class="post-metadata">

**Author:** ![chrish](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.gitea.com/chrish/32/2570_2.png) [@chrish](https://forum.gitea.com/u/chrish)\
**Post date:** [July 26, 2022, 12:54am UTC](https://forum.gitea.com/t/a-gentle-introduction-to-the-gitea-doctor-blog/5358/8 "2022-07-26T00:54:23Z")

</div>

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

```auto
[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

---

<div class="post-metadata">

**Author:** ![dachary](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.gitea.com/dachary/32/4990_2.png) [@dachary](https://forum.gitea.com/u/dachary)\
**Post date:** [July 26, 2022, 5:22am UTC](https://forum.gitea.com/t/a-gentle-introduction-to-the-gitea-doctor-blog/5358/9 "2022-07-26T05:22:02Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![chrish](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.gitea.com/chrish/32/2570_2.png) [@chrish](https://forum.gitea.com/u/chrish)\
**Post date:** [July 26, 2022, 5:35am UTC](https://forum.gitea.com/t/a-gentle-introduction-to-the-gitea-doctor-blog/5358/10 "2022-07-26T05:35:51Z")

</div>

I 'm running 1.16.5 with Go 1.18

---

<div class="post-metadata">

**Author:** ![dachary](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.gitea.com/dachary/32/4990_2.png) [@dachary](https://forum.gitea.com/u/dachary)\
**Post date:** [July 26, 2022, 6:55am UTC](https://forum.gitea.com/t/a-gentle-introduction-to-the-gitea-doctor-blog/5358/11 "2022-07-26T06:55:13Z")

</div>

> [@chrish](#):
>
> By doing the above it broke our Gitea Server. No one could post any commits by any means (ssh or web UI).

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?
