{"record":{"id":"23e541bb3f6ee3ad","repo":"diegosouzapw/OmniRoute","slug":"db-cannot-create-data-directory-data-dir","errorCode":null,"errorMessage":"[DB] Cannot create data directory '${DATA_DIR}': ${msg}","messagePattern":"\\[DB\\] Cannot create data directory '(.+?)': (.+?)","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/lib/db/core.ts","lineNumber":228,"sourceCode":"        `sql.js (falhou: ${preInitError}).`\n    );\n  }\n\n  throw new Error(\n    `[DB] Nenhum driver SQLite disponível para '${sqliteFile}'. ` +\n      \"Chame ensureDbInitialized() no startup. \" +\n      `Drivers testados: ${syncDrivers}. ` +\n      \"sql.js WASM ainda não foi pré-inicializado.\"\n  );\n}\n\n// Ensure data directory exists — with fallback for restricted home directories (#133)\nif (!isCloud && !fs.existsSync(DATA_DIR)) {\n  try {\n    fs.mkdirSync(DATA_DIR, { recursive: true });\n  } catch (err: unknown) {\n    const msg = err instanceof Error ? err.message : String(err);\n    console.warn(\n      `[DB] Cannot create data directory '${DATA_DIR}': ${msg}\\n` +\n        `[DB] Set the DATA_DIR environment variable to a writable path, e.g.:\\n` +\n        `[DB]   DATA_DIR=/path/to/writable/dir omniroute`\n    );\n  }\n}\n\n// ──────────────── Schema ────────────────\n\nconst SCHEMA_SQL = `\n  CREATE TABLE IF NOT EXISTS provider_connections (\n    id TEXT PRIMARY KEY,\n    provider TEXT NOT NULL,\n    auth_type TEXT,\n    name TEXT,\n    email TEXT,\n    priority INTEGER DEFAULT 0,\n    is_active INTEGER DEFAULT 1,","sourceCodeStart":210,"sourceCodeEnd":246,"githubUrl":"https://github.com/diegosouzapw/OmniRoute/blob/a179ffed5bb2e0b883b9ae7214ce8717b2a94c4d/src/lib/db/core.ts#L210-L246","documentation":"Creating the OmniRoute data directory (DATA_DIR, default ~/.omniroute) failed with a filesystem error — typically permission denial or a read-only home directory. This is the restricted-home fallback path (#133): the warning is emitted and the system falls back to an alternative location (or continues without the directory), affecting where the SQLite database and artifacts are stored.","triggerScenarios":"Thrown at src/lib/db/core.ts:228 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Check permissions on the home directory / DATA_DIR path","Set DATA_DIR env var to a writable location","For sandboxed/containerized runs, mount a writable volume at the chosen DATA_DIR"],"exampleFix":null,"handlingStrategy":"fallback","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"a179ffed5bb2e0b883b9ae7214ce8717b2a94c4d","analyzedAt":"2026-08-25T18:35:09.898Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}