diegosouzapw/OmniRoute · error

[DB] Cannot create data directory

Error message

[DB] Cannot create data directory '${DATA_DIR}': ${msg}

What it means

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.

Solutions

  1. Check permissions on the home directory / DATA_DIR path
  2. Set DATA_DIR env var to a writable location
  3. For sandboxed/containerized runs, mount a writable volume at the chosen DATA_DIR
Defensive patterns

Strategy: fallback

When it happens

Trigger: Thrown at src/lib/db/core.ts:228 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of diegosouzapw/OmniRoute@a179ffed5b (2026-08-25). Data as JSON: /api/errors/23e541bb3f6ee3ad. Report an issue: GitHub.

Appendix: source

Thrown at src/lib/db/core.ts:228

        `sql.js (falhou: ${preInitError}).`
    );
  }

  throw new Error(
    `[DB] Nenhum driver SQLite disponível para '${sqliteFile}'. ` +
      "Chame ensureDbInitialized() no startup. " +
      `Drivers testados: ${syncDrivers}. ` +
      "sql.js WASM ainda não foi pré-inicializado."
  );
}

// Ensure data directory exists — with fallback for restricted home directories (#133)
if (!isCloud && !fs.existsSync(DATA_DIR)) {
  try {
    fs.mkdirSync(DATA_DIR, { recursive: true });
  } catch (err: unknown) {
    const msg = err instanceof Error ? err.message : String(err);
    console.warn(
      `[DB] Cannot create data directory '${DATA_DIR}': ${msg}\n` +
        `[DB] Set the DATA_DIR environment variable to a writable path, e.g.:\n` +
        `[DB]   DATA_DIR=/path/to/writable/dir omniroute`
    );
  }
}

// ──────────────── Schema ────────────────

const SCHEMA_SQL = `
  CREATE TABLE IF NOT EXISTS provider_connections (
    id TEXT PRIMARY KEY,
    provider TEXT NOT NULL,
    auth_type TEXT,
    name TEXT,
    email TEXT,
    priority INTEGER DEFAULT 0,
    is_active INTEGER DEFAULT 1,

View on GitHub (pinned to a179ffed5b)