Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to open database file: The system cannot find the path specified #28300

Closed
yp05327 opened this issue Nov 30, 2023 · 9 comments · Fixed by #28374
Closed

Unable to open database file: The system cannot find the path specified #28300

yp05327 opened this issue Nov 30, 2023 · 9 comments · Fixed by #28374
Labels

Comments

@yp05327
Copy link
Contributor

yp05327 commented Nov 30, 2023

Description

On windows:
image

Gitea Version

1.21.0

Can you reproduce the bug on the Gitea demo site?

No

Log Gist

No response

Screenshots

No response

Git Version

No response

Operating System

No response

How are you running Gitea?

gitea-1.21.0-windows-4.0-amd64.exe

Database

None

@yp05327
Copy link
Contributor Author

yp05327 commented Nov 30, 2023

After I created data folder manually. It worked.

@KazzmanK
Copy link
Contributor

It was something about this earlier....

@yp05327
Copy link
Contributor Author

yp05327 commented Dec 1, 2023

@lunny
We call checkDatabase before PrepareAppDataPath which partly caused this issue,
because this will not happen in Linux, so maybe it is also related to XORM?

@lunny
Copy link
Member

lunny commented Dec 5, 2023

@lunny We call checkDatabase before PrepareAppDataPath which partly caused this issue, because this will not happen in Linux, so maybe it is also related to XORM?

Why call checkDatabase before PrepareAppDataPath will cause the issue?

@yp05327
Copy link
Contributor Author

yp05327 commented Dec 6, 2023

@lunny We call checkDatabase before PrepareAppDataPath which partly caused this issue, because this will not happen in Linux, so maybe it is also related to XORM?

Why call checkDatabase before PrepareAppDataPath will cause the issue?

Maybe this is not related. This issue start/come from v1.20.1

@yp05327
Copy link
Contributor Author

yp05327 commented Dec 6, 2023

This is caused by #25944.
Before this patch, when Gitea start, data folder will be created automatically.
After this patch, data folder will not be created, which caused this issue.

When we call checkDatabase, XORM will try to open data/gitea.db by default, but data folder does not exist.
And it seems that XORM will not automatically create folder when gitea.db is in an non-exist folder in windows.

@yp05327
Copy link
Contributor Author

yp05327 commented Dec 6, 2023

For example, you can modified the code here:
image

Then build and run Gitea in linux.
After click the install button, checkDatabase will return true, and we have modified the code above, so it will return and not run the codes below.
Then you can see an empty gitea.db in data folder:
image
(gitea.db is empty)
image
So we can know that in linux, checkDatabase will create both data folder and gitea.db.
And I think this is done by XORM.

Then build a windows version without any modify and run it in windows.
After click the install button, checkDatabase will return false, and we didn't modify the code above, so it will return and not run the codes below.
Then you can see that nothing changed in the root path. No data folder and of cause no gitea.db.

After more tests, I found that checkDatabase will return false here:
image

In CheckDatabaseConnection, all operations are handled by XORM I think, so it seems that there's a bug in XORM when OS is windows?
image

@wxiaoguang
Copy link
Contributor

This is caused by #25944.
Before this patch, when Gitea start, data folder will be created automatically.
After this patch, data folder will not be created, which caused this issue.

Even if there is no #25944, if you set Path to a new one but not the default "data", I think you will still see the same error.

So I do not think it's a regression, but it indeed is a bad design of directory handling in Gitea.

@wxiaoguang
Copy link
Contributor

The fix should be this: Fix incorrect directory path handling for SQLite3 database file #28374

jolheiser pushed a commit that referenced this issue Dec 6, 2023
) (#28378)

Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
Fix #28300
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jan 21, 2024
project-mirrors-bot-tu bot pushed a commit to project-mirrors/forgejo-as-gitea-fork that referenced this issue Jan 23, 2025
…gitea#28374) (go-gitea#28378)

Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
Fix go-gitea#28300

(cherry picked from commit 5eaf91e)
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants