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

**URL:** <https://forum.gitea.com/t/fresh-installation-of-gitea-1-13-2-have-to-create-a-folder-named-gitea/2980>\
**Category:** General\
**Created:** [February 17, 2021, 11:20pm UTC](https://forum.gitea.com/t/fresh-installation-of-gitea-1-13-2-have-to-create-a-folder-named-gitea/2980 "2021-02-17T23:20:37Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![uli-heller](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.gitea.com/uli-heller/32/1119_2.png) [@uli-heller](https://forum.gitea.com/u/uli-heller)\
**Post date:** [February 17, 2021, 11:20pm UTC](https://forum.gitea.com/t/fresh-installation-of-gitea-1-13-2-have-to-create-a-folder-named-gitea/2980/1 "2021-02-17T23:20:37Z")

</div>

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:

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

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

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

---

<div class="post-metadata">

**Author:** ![somera](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.gitea.com/somera/32/641_2.png) [@somera](https://forum.gitea.com/u/somera)\
**Post date:** [February 20, 2021, 9:26pm UTC](https://forum.gitea.com/t/fresh-installation-of-gitea-1-13-2-have-to-create-a-folder-named-gitea/2980/2 "2021-02-20T21:26:29Z")

</div>

How do you added the gitea user?

> **[Installation from binary - Docs](https://docs.gitea.io/en-us/install-from-binary/#prepare-environment)**

---

<div class="post-metadata">

**Author:** ![uli-heller](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.gitea.com/uli-heller/32/1119_2.png) [@uli-heller](https://forum.gitea.com/u/uli-heller)\
**Post date:** [February 21, 2021, 5:48am UTC](https://forum.gitea.com/t/fresh-installation-of-gitea-1-13-2-have-to-create-a-folder-named-gitea/2980/3 "2021-02-21T05:48:45Z")

</div>

@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

---

<div class="post-metadata">

**Author:** ![uli-heller](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.gitea.com/uli-heller/32/1119_2.png) [@uli-heller](https://forum.gitea.com/u/uli-heller)\
**Post date:** [February 21, 2021, 7:21am UTC](https://forum.gitea.com/t/fresh-installation-of-gitea-1-13-2-have-to-create-a-folder-named-gitea/2980/4 "2021-02-21T07:21:54Z")

</div>

@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:

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

```

Ansible shows this:

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

---

<div class="post-metadata">

**Author:** ![somera](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.gitea.com/somera/32/641_2.png) [@somera](https://forum.gitea.com/u/somera)\
**Post date:** [February 21, 2021, 11:09am UTC](https://forum.gitea.com/t/fresh-installation-of-gitea-1-13-2-have-to-create-a-folder-named-gitea/2980/5 "2021-02-21T11:09:28Z")

</div>

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

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

---

<div class="post-metadata">

**Author:** ![somera](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.gitea.com/somera/32/641_2.png) [@somera](https://forum.gitea.com/u/somera)\
**Post date:** [February 21, 2021, 11:19am UTC](https://forum.gitea.com/t/fresh-installation-of-gitea-1-13-2-have-to-create-a-folder-named-gitea/2980/6 "2021-02-21T11:19:00Z")

</div>

I found this: [GitHub - thomas-maurice/ansible-role-gitea: Ansible role to deploy a Gitea instance](https://github.com/thomas-maurice/ansible-role-gitea)

---

<div class="post-metadata">

**Author:** ![uli-heller](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.gitea.com/uli-heller/32/1119_2.png) [@uli-heller](https://forum.gitea.com/u/uli-heller)\
**Post date:** [February 21, 2021, 3:32pm UTC](https://forum.gitea.com/t/fresh-installation-of-gitea-1-13-2-have-to-create-a-folder-named-gitea/2980/7 "2021-02-21T15:32:28Z")

</div>

@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:

```diff
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

```
