Using absolute path in app.ini #1398

Closed
opened 2025-11-02 03:59:32 -06:00 by GiteaMirror · 12 comments
Owner

Originally created by @johnroyer on GitHub (Dec 22, 2017).

Environment detials :

  • Gitea version : v1.3.2
  • Git version: 2.15.1
  • Operating system: Ubuntu 14.04
  • Database (use [x]):
    • PostgreSQL
    • MySQL
    • MSSQL
    • SQLite
  • Can you reproduce the bug at https://try.gitea.io:
    • Yes (provide example URL)
    • No
    • Not relevant
  • Log gist:

Description

I put binary file gitea-1.3.2-linux-amd64 in this path /home/git/gitea. And then add a script in crontab to auto bootup:

@reboot   /home/git/gitea/gitea-1.3.2-linux-amd64 web > /home/git/gitea/run.log 2>&1

After reboot, Gitea bootup as expected. But I can not login in any way.

I try this out:

  1. cd /home/git/gitea && gitea-1.3.2-linux-amd64 web => work fine
  2. cd /home/git && gitea-1.3.2-linux-amd64 web => can not login

I notice that Gitea write the sqlite DB path in relative format:

[database]
DB_TYPE  = sqlite3
HOST     = 127.0.0.1:3306
NAME     = gitea
USER     = gitea
PASSWD   = 
SSL_MODE = disable
PATH     = data/gitea.db

Then I modify the path in absolute format:

PATH     = /home/git/gitea/data/gitea.db

And then evenything works fine.

I think Gitea does not check it's binary path, so it can not exactly find sqlite DB if user does not run Gitea in the same path where Gitea is. Maybe saving absolute path for sqlite DB is better.

Originally created by @johnroyer on GitHub (Dec 22, 2017). Environment detials : - Gitea version : `v1.3.2` - Git version: `2.15.1` - Operating system: `Ubuntu 14.04` - Database (use `[x]`): - [ ] PostgreSQL - [ ] MySQL - [ ] MSSQL - [x] SQLite - Can you reproduce the bug at https://try.gitea.io: - [ ] Yes (provide example URL) - [ ] No - [x] Not relevant - Log gist: ## Description I put binary file `gitea-1.3.2-linux-amd64` in this path `/home/git/gitea`. And then add a script in crontab to auto bootup: ```cron @reboot /home/git/gitea/gitea-1.3.2-linux-amd64 web > /home/git/gitea/run.log 2>&1 ``` After reboot, Gitea bootup as expected. But I can not login in any way. I try this out: 1. `cd /home/git/gitea && gitea-1.3.2-linux-amd64 web` => work fine 1. `cd /home/git && gitea-1.3.2-linux-amd64 web` => can not login I notice that Gitea write the sqlite DB path in relative format: ```ini [database] DB_TYPE = sqlite3 HOST = 127.0.0.1:3306 NAME = gitea USER = gitea PASSWD = SSL_MODE = disable PATH = data/gitea.db ``` Then I modify the path in absolute format: ```ini PATH = /home/git/gitea/data/gitea.db ``` And then evenything works fine. I think Gitea does not check it's binary path, so it can not exactly find sqlite DB if user does not run Gitea in the same path where Gitea is. Maybe saving absolute path for sqlite DB is better.
GiteaMirror added the type/questionissue/not-a-bug labels 2025-11-02 03:59:33 -06:00
Author
Owner

@lafriks commented on GitHub (Dec 22, 2017):

Relative path should be not from binary but from current working directory so I don't see a problem here

@lafriks commented on GitHub (Dec 22, 2017): Relative path should be not from binary but from current working directory so I don't see a problem here
Author
Owner

@johnroyer commented on GitHub (Dec 22, 2017):

I don't understand. is it means I should manually set the correct path in app.ini ?

@johnroyer commented on GitHub (Dec 22, 2017): I don't understand. is it means I should manually set the correct path in `app.ini` ?
Author
Owner

@lafriks commented on GitHub (Dec 22, 2017):

current working path (cwd) - is the one you cd into. It is used for relative paths.
You set it using either cd when run manually on in services script, or using GITEA_WORK_DIR environment variable

@lafriks commented on GitHub (Dec 22, 2017): current working path (cwd) - is the one you cd into. It is used for relative paths. You set it using either cd when run manually on in services script, or using `GITEA_WORK_DIR` environment variable
Author
Owner

@johnroyer commented on GitHub (Dec 22, 2017):

I found the document here:

Then change the crontab script from:

@reboot   /home/git/gitea/gitea-1.3.2-linux-amd64 web > /home/git/gitea/run.log 2>&1

to:

@reboot   GITEA_WORK_DIR="/home/git/gitea" /home/git/gitea/gitea-1.3.2-linux-amd64 web > /home/git/gitea/run.log 2>&1

But I still get the same problem. any ideas ?

@johnroyer commented on GitHub (Dec 22, 2017): I found the document here: [](https://docs.gitea.io/en-us/specific-variables/) Then change the crontab script from: ``` @reboot /home/git/gitea/gitea-1.3.2-linux-amd64 web > /home/git/gitea/run.log 2>&1 ``` to: ``` @reboot GITEA_WORK_DIR="/home/git/gitea" /home/git/gitea/gitea-1.3.2-linux-amd64 web > /home/git/gitea/run.log 2>&1 ``` But I still get the same problem. any ideas ?
Author
Owner

@lafriks commented on GitHub (Dec 22, 2017):

What do you get in log file?

@lafriks commented on GitHub (Dec 22, 2017): What do you get in log file?
Author
Owner

@johnroyer commented on GitHub (Dec 22, 2017):

Seems normal:

[Macaron] 2017-12-22 15:14:20: Started POST /user/login for 127.0.0.1
[Macaron] 2017-12-22 15:14:20: Completed /user/login 200 OK in 3.811322ms
[Macaron] 2017-12-22 15:17:40: Started POST /user/login for [::1]
[Macaron] 2017-12-22 15:17:40: Completed /user/login 200 OK in 3.065907ms

I can not find error or warning messages whenever sqlite is found or not.

@johnroyer commented on GitHub (Dec 22, 2017): Seems normal: ``` [Macaron] 2017-12-22 15:14:20: Started POST /user/login for 127.0.0.1 [Macaron] 2017-12-22 15:14:20: Completed /user/login 200 OK in 3.811322ms [Macaron] 2017-12-22 15:17:40: Started POST /user/login for [::1] [Macaron] 2017-12-22 15:17:40: Completed /user/login 200 OK in 3.065907ms ``` I can not find error or warning messages whenever sqlite is found or not.
Author
Owner

@lafriks commented on GitHub (Dec 22, 2017):

When gitea starts it prints current working dir etc at the begining. What are values there? (should be at the begining of log)

@lafriks commented on GitHub (Dec 22, 2017): When gitea starts it prints current working dir etc at the begining. What are values there? (should be at the begining of log)
Author
Owner

@johnroyer commented on GitHub (Dec 22, 2017):

logs when startup:

$ cd /home/git
$ GITEA_WORK_DIR="/home/git/gitea" /home/git/gitea/gitea-1.3.2-linux-amd64 web 
2017/12/22 16:52:02 [T] AppPath: /home/git/gitea/gitea-1.3.2-linux-amd64
2017/12/22 16:52:02 [T] AppWorkPath: /home/git/gitea
2017/12/22 16:52:02 [T] Custom path: /home/git/gitea/custom
2017/12/22 16:52:02 [T] Log path: /home/git/gitea/log
2017/12/22 16:52:02 [I] Gitea v1.3.2 built with: bindata, sqlite
2017/12/22 16:52:02 Serving [::]:8080 with pid 24679
@johnroyer commented on GitHub (Dec 22, 2017): logs when startup: ``` $ cd /home/git $ GITEA_WORK_DIR="/home/git/gitea" /home/git/gitea/gitea-1.3.2-linux-amd64 web 2017/12/22 16:52:02 [T] AppPath: /home/git/gitea/gitea-1.3.2-linux-amd64 2017/12/22 16:52:02 [T] AppWorkPath: /home/git/gitea 2017/12/22 16:52:02 [T] Custom path: /home/git/gitea/custom 2017/12/22 16:52:02 [T] Log path: /home/git/gitea/log 2017/12/22 16:52:02 [I] Gitea v1.3.2 built with: bindata, sqlite 2017/12/22 16:52:02 Serving [::]:8080 with pid 24679 ```
Author
Owner

@johnroyer commented on GitHub (Dec 22, 2017):

I notice that Gitea can get correct work path even I do not set the environment variable:

$ cd /homr/git
$ gitea/gitea-1.3.2-linux-amd64 web
2017/12/22 16:59:40 [T] AppPath: /home/git/gitea/gitea-1.3.2-linux-amd64
2017/12/22 16:59:40 [T] AppWorkPath: /home/git/gitea
2017/12/22 16:59:40 [T] Custom path: /home/git/gitea/custom
2017/12/22 16:59:40 [T] Log path: /home/git/gitea/log
2017/12/22 16:59:40 [I] Gitea v1.3.2 built with: bindata, sqlite
2017/12/22 16:59:40 Serving [::]:8080 with pid 27105
@johnroyer commented on GitHub (Dec 22, 2017): I notice that Gitea can get correct work path even I do not set the environment variable: ``` $ cd /homr/git $ gitea/gitea-1.3.2-linux-amd64 web 2017/12/22 16:59:40 [T] AppPath: /home/git/gitea/gitea-1.3.2-linux-amd64 2017/12/22 16:59:40 [T] AppWorkPath: /home/git/gitea 2017/12/22 16:59:40 [T] Custom path: /home/git/gitea/custom 2017/12/22 16:59:40 [T] Log path: /home/git/gitea/log 2017/12/22 16:59:40 [I] Gitea v1.3.2 built with: bindata, sqlite 2017/12/22 16:59:40 Serving [::]:8080 with pid 27105 ```
Author
Owner

@lafriks commented on GitHub (Dec 22, 2017):

But if your sqlite db is located at /home/git/gitea/data/gitea.db it should work fine with PATH = data/gitea.db

@lafriks commented on GitHub (Dec 22, 2017): But if your sqlite db is located at `/home/git/gitea/data/gitea.db` it should work fine with `PATH = data/gitea.db`
Author
Owner

@danielfbm commented on GitHub (Dec 28, 2017):

+1 for absolute paths in app.ini, this helps to have a clear configuration file instead of context based.

@danielfbm commented on GitHub (Dec 28, 2017): +1 for absolute paths in app.ini, this helps to have a clear configuration file instead of context based.
Author
Owner

@techknowlogick commented on GitHub (May 16, 2018):

Closing this issue

@techknowlogick commented on GitHub (May 16, 2018): Closing this issue
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/gitea#1398