{"record":{"id":"0ba79d2151892150","repo":"1Panel-dev/1Panel","slug":"init-db-dir-failed-err-v-0ba79d","errorCode":null,"errorMessage":"init db dir failed, err: %v","messagePattern":"init db dir failed, err: (.+?)","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"core/utils/common/sqlite.go","lineNumber":17,"sourceCode":"package common\n\nimport (\n\t\"fmt\"\n\t\"log\"\n\t\"os\"\n\t\"path\"\n\t\"time\"\n\n\t\"github.com/glebarez/sqlite\"\n\t\"gorm.io/gorm\"\n\t\"gorm.io/gorm/logger\"\n)\n\nfunc LoadDBConnByPath(fullPath, dbName string) *gorm.DB {\n\tif _, err := CreateDirWhenNotExist(true, path.Dir(fullPath)); err != nil {\n\t\tpanic(fmt.Errorf(\"init db dir failed, err: %v\", err))\n\t}\n\tif _, err := os.Stat(fullPath); err != nil {\n\t\tf, err := os.Create(fullPath)\n\t\tif err != nil {\n\t\t\tpanic(fmt.Errorf(\"init %s db file failed, err: %v\", dbName, err))\n\t\t}\n\t\t_ = f.Close()\n\t}\n\n\tdb, err := GetDBWithPath(fullPath)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\treturn db\n}\n\nfunc CloseDB(db *gorm.DB) {\n\tsqlDB, err := db.DB()","sourceCodeStart":1,"sourceCodeEnd":35,"githubUrl":"https://github.com/1Panel-dev/1Panel/blob/5ac7c808815b0691009cd390414f03471312262f/core/utils/common/sqlite.go#L1-L35","documentation":"Error \"init db dir failed, err: %v\" thrown in 1Panel-dev/1Panel.","triggerScenarios":"Thrown at core/utils/common/sqlite.go:17 when the library encounters an invalid state.","commonSituations":"Occurs when LoadDBConnByPath cannot create the parent directory for the sqlite database file (missing permissions, read-only filesystem, or invalid path). The process panics immediately. Defense: ensure the data directory exists and is writable by the service account before startup; check disk space and mount status; do not retry in a loop because the panic indicates a persistent environment problem.","solutions":["Check that the parent directory of the database path exists and that the 1Panel core process has write permission to create it.","Verify the filesystem is not full (`df -h`) and not mounted read-only (`mount | grep <dir>`).","Ensure the configured install/base directory is valid and on a local filesystem that supports directory creation.","Create the directory manually with correct ownership (e.g. `mkdir -p <dir> && chown <user>:<group> <dir>`) and restart the service."],"exampleFix":"mkdir -p /opt/1panel/db && chown -R root:root /opt/1panel/db && systemctl restart 1panel","handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"5ac7c808815b0691009cd390414f03471312262f","analyzedAt":"2026-08-15T14:02:06.953Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}