# SyncRepositoryHook permission denied

**URL:** <https://forum.gitea.com/t/syncrepositoryhook-permission-denied/6881>\
**Category:** Install/Maintain/Configure\
**Created:** [March 16, 2023, 8:06am UTC](https://forum.gitea.com/t/syncrepositoryhook-permission-denied/6881 "2023-03-16T08:06:17Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Heinz](https://avatars.discourse-cdn.com/v4/letter/h/f04885/32.png) [@Heinz](https://forum.gitea.com/u/Heinz)\
**Post date:** [March 16, 2023, 8:06am UTC](https://forum.gitea.com/t/syncrepositoryhook-permission-denied/6881/1 "2023-03-16T08:06:17Z")

</div>

Hello together,

I updated Gitea 1.16.8 to 1.18.3 (suse linux 15.3.).  
After the update, gitea no longer starts, the following error occurs:

[Gitea - Code](http://code.gitea.io/gitea/services/repository). **SyncRepositoryHooks** (ctx) failed: SyncRepositoryHook: unable to pre-remove old hook file ‘/opt/gitea/repositories/giteaadmin/ordirob.git/hooks/pre-receive’ prior to rewriting: remove /opt/gitea/repositories/giteaadmin/ordirob.git/hooks/pre-receive: **permission denied**

Before the update everything was working fine.  
Does anyone have an idea what’s going wrong?

---

<div class="post-metadata">

**Author:** ![jake](https://avatars.discourse-cdn.com/v4/letter/j/f475e1/32.png) [@jake](https://forum.gitea.com/u/jake)\
**Post date:** [March 19, 2023, 3:42am UTC](https://forum.gitea.com/t/syncrepositoryhook-permission-denied/6881/2 "2023-03-19T03:42:56Z")

</div>

> `remove /opt/gitea/repositories/giteaadmin/ordirob.git/hooks/pre-receive: permission denied`

This error is saying Gitea is not able to modify the files at that location. Make sure that Gitea is running as the right user/group and that those directories are accessible by that user/group.

You may also be running into an issue with MAC like AppArmor or SELinux, you can check their audit logs to see if they’re the reason behind it.

---

<div class="post-metadata">

**Author:** ![Heinz](https://avatars.discourse-cdn.com/v4/letter/h/f04885/32.png) [@Heinz](https://forum.gitea.com/u/Heinz)\
**Post date:** [March 27, 2023, 8:12am UTC](https://forum.gitea.com/t/syncrepositoryhook-permission-denied/6881/3 "2023-03-27T08:12:53Z")

</div>

Thanks for your reply Jake.  
Gitea works with the right user, the permissions on the directories match.

Meanwhile I did an update to a 1.17.x version. The problem here was now, that new repositories could not be created via the gitea WEB-UI - because of permission denied on the repository directory.  
Only with a gitea 1.16.x version do these problems not occur in my environment. I now suspect that something is running on the server that interferes with gitea.

---

<div class="post-metadata">

**Author:** ![jake](https://avatars.discourse-cdn.com/v4/letter/j/f475e1/32.png) [@jake](https://forum.gitea.com/u/jake)\
**Post date:** [March 27, 2023, 9:14pm UTC](https://forum.gitea.com/t/syncrepositoryhook-permission-denied/6881/4 "2023-03-27T21:14:13Z")

</div>

You might be running into the switch from using the gitconfig at `$HOME/.gitconfig` to a path specified in app.ini which occurred in 1.17.x. See [Internal Gitconfig](https://blog.gitea.io/2022/07/gitea-1.17.0-is-released/#-internal-gitconfig-19732httpsgithubcomgo-giteagiteapull19732) and [Config Cheat Sheet](https://docs.gitea.io/en-us/config-cheat-sheet/#git-git). It could also be an issue where an antivirus or other process is scanning files and Gitea tries to access the file at the same time the other process does.

If that’s not it, could you post your scrubbed app.ini and the full debug logs from Gitea starting to the error (set `[log] LEVEL=Debug`)?  
To make it easier to read, you can format it like this to make it show nicely on Discourse.  
```  
[logs]  
```

---

<div class="post-metadata">

**Author:** ![Heinz](https://avatars.discourse-cdn.com/v4/letter/h/f04885/32.png) [@Heinz](https://forum.gitea.com/u/Heinz)\
**Post date:** [March 29, 2023, 11:22am UTC](https://forum.gitea.com/t/syncrepositoryhook-permission-denied/6881/5 "2023-03-29T11:22:39Z")

</div>

Thank you for these valuable tips!  
I’ll take a look and report back with results. But it can take a while… 😉
