Monday, December 18, 2023

Gogs: Internal Error from "git push"

This might have been fixed in Gogs, and maybe it just got me because I'm just running an older version, but I think it's worth a quick post here anyway...

Problem

Pushing a git repository to a remote hosted in Gogs... with ssh config, etc. all as it should be... results in:

me@myworkstation#:~/mylocalgitclonedir $ git push

Gogs: Internal error

fatal: Could not read from remote repository.


Please make sure you have the correct access rights

and the repository exists.

Cause

It turned out to be root:root ownership of the xorm.log file on the Gogs server.

In my case, running in a docker container, that was /app/gogs/log/xorm.log

This might be related: https://github.com/gogs/gogs/issues/4990

Don't know how this got changed in my particular setup... yet.  Maybe a backup or log rotation hiccup.

So, the cause was not: (including some of this for searchability of this article)

  • repository write permissions for user
  • SSH config on server or client
    • i.e. not an ssh client known_hosts error
    • i.e. not related to private key file permissions on the client
    • i.e. not using the wrong private key for the registered public key in gogs
    • checked with command:  ssh -v -T git@mygogshost

Solution

Open a terminal on the gogs host, and...

sudo chown git:git /app/gogs/log/xorm.log

After that git push worked fine again.

References

  • https://github.com/gogs/gogs/issues/4990

2 comments:

Whirly said...

FWIW, the Gogs version affected by this, in my case, was 0.11.43.0330. As mentioned in the linked Github issue, it is fixed in version 0.12.3.

Whirly said...

This is still happening with Gogs version 0.13.0 (which is current as of now - April 2024), even though the related issues on Github say it was resolved. Still poking around to see if I can find what is doing log rotation, and why it is leaving the xorm.log file owned by root. Will post here if I ever find a way to fix it.