Fresh installation of gitea-1.13.2 - have to create a folder named ~gitea/~

I’m preparing a fresh gitea instance. Unfortunately, it doesn’t start up.
I’m using ubuntu-20.04 and gitea-1.13.2.

Within the system journal journalctl -xe, I get these errors:

Feb 18 00:06:02 dp-gitea gitea[89199]: 2021/02/18 00:06:02 ...dules/setting/git.go:91:newGit() [I] Git Version: 2.25.1, Wire Protocol Version 2 Enabled
Feb 18 00:06:02 dp-gitea gitea[89199]: 2021/02/18 00:06:02 routers/init.go:129:GlobalInit() [F] Git module init failed: Failed to set git user.name(exec(3:git.Init(set user.name)) failed: exit status 255(<nil>) stdout:  stderr: error: could not lock config file ~/.gitconfig: Permission denied
Feb 18 00:06:02 dp-gitea gitea[89199]:         ): error: could not lock config file ~/.gitconfig: Permission denied
Feb 18 00:06:02 dp-gitea gitea[89199]:         
Feb 18 00:06:02 dp-gitea systemd[1]: gitea.service: Main process exited, code=exited, status=1/FAILURE
-- Subject: Unit process exited
-- Defined-By: systemd
-- Support: http://www.ubuntu.com/support
-- 
-- An ExecStart= process belonging to unit gitea.service has exited.
-- 
-- The process' exit code is 'exited' and its exit status is 1.
Feb 18 00:06:02 dp-gitea systemd[1]: gitea.service: Failed with result 'exit-code'.

I do know the special behavior of “~” and its relation to $HOME.
Normally, I would assume that gitea is trying to open a file named “.gitconfig” within the
home folder of the user executing the gitea command (named “gitea” in my case).

Looking at ~gitea, I see the file exists:

root@dp-gitea:~/systemd# ls -la ~gitea
...
-rw-rw-r-- 1 gitea gitea  162 Feb 17 20:42  .gitconfig

At some point, I got the idea to create “~gitea/~”. After this, gitea does start up.
After starting gitea, a file named “~gitea/~/.gitconfig” got created:

root@dp-gitea:~/systemd# ls -la ~gitea
...
drwxr-xr-x 1 gitea gitea   20 Feb 18 00:06 '~'
...
root@dp-gitea:~/systemd# ls -la ~gitea/~
total 4
drwxr-xr-x 1 gitea gitea  20 Feb 18 00:06 .
drwxr-xr-x 1 gitea gitea 110 Feb 18 00:05 ..
-rw-r--r-- 1 gitea gitea 162 Feb 18 00:06 .gitconfig

Pretty ugly, but it works.

Afterwards, I tried changing the login shell of the user “gitea” from /bin/sh to /bin/bash, no success. The folder “~gitea/~” is still required.

Do you have any idea how I can get rid off this ugly folder? Thx, Uli

How do you added the gitea user?

@somera : Thanks a lot for taking the time looking into this.
The only difference from what I see is that I used /bin/sh instead of /bin/bash, although I changed to /bin/bash later on

1 Like

@somera : I started from scratch. This time, I created the gitea user using bash. Unfortunately, no improvement. I still need the folder “~gitea/~” to run gitea.

Here is how I create the user using ansible:

- name: create the gitea user
  user:
    name: gitea
    comment: 'Gitea'
    shell: /bin/bash
    password_lock: yes

Ansible shows this:

changed: [gitea] => {
    "ansible_facts": {
        "discovered_interpreter_python": "/usr/bin/python3"
    },
    "changed": true,
    "comment": "Gitea",
    "create_home": true,
    "group": 1001,
    "home": "/home/gitea",
    "name": "gitea",
    "shell": "/bin/bash",
    "state": "present",
    "system": false,
    "uid": 1001
}

I guess it is pretty similar to what is mentioned within the docs…

ok. You do this with ansible. The error say, that the user git has no write permission to ~ (-> but what exactly is ~?)

The gitea process should run as gitea user.

And have you add this

mkdir -p /var/lib/gitea/{custom,data,log}
chown -R git:git /var/lib/gitea/
chmod -R 750 /var/lib/gitea/
mkdir /etc/gitea
chown root:git /etc/gitea
chmod 770 /etc/gitea

too? can you post the whole ansible script?

I found this: GitHub - thomas-maurice/ansible-role-gitea: Ansible role to deploy a Gitea instance

@somera : I found my mistake. Sorry for wasting your time but thx a lot for your efforts. Your findings related to ansible look very good.

My mistake within gitea.service:

root@gitea:/home/gitea# diff -u /etc/systemd/system/gitea.service*
--- /etc/systemd/system/gitea.service	2021-02-21 16:29:04.952692183 +0100
+++ /etc/systemd/system/gitea.service~	2021-02-21 16:26:47.000000000 +0100
@@ -56,7 +56,7 @@
 #RuntimeDirectory=gitea
 ExecStart=/srv/gitea/gitea --custom-path /srv/gitea/custom --work-path /srv/gitea/work
 Restart=always
+Environment=USER=gitea HOME=/home/gitea GITEA_WORK_DIR=/srv/gitea/work GITEA_CUSTOM=/srv/gitea/custom
-Environment=USER=gitea HOME=~ GITEA_WORK_DIR=/srv/gitea/work GITEA_CUSTOM=/srv/gitea/custom
 # If you install Git to directory prefix other than default PATH (which happens
 # for example if you install other versions of Git side-to-side with
 # distribution version), uncomment below line and add that prefix to PATH
1 Like