{"record":{"id":"8bc2328faaccde99","repo":"denoland/deno","slug":"failed-to-open-cache-db-at","errorCode":null,"errorMessage":"failed to open cache db at {}","messagePattern":"failed to open cache db at (.+?)","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"ext/cache/sqlite.rs","lineNumber":112,"sourceCode":"      .as_str()\n    {\n      \"disk\" | \"\" => Mode::Disk,\n      \"memory\" => Mode::InMemory,\n      _ => {\n        log::warn!(\"Unknown DENO_CACHE_DB_MODE value, defaulting to disk\");\n        Mode::Disk\n      }\n    };\n\n    let connection = if matches!(mode, Mode::InMemory) {\n      rusqlite::Connection::open_in_memory()\n        .unwrap_or_else(|_| panic!(\"failed to open in-memory cache db\"))\n    } else {\n      create_cache_storage_dir(&cache_storage_dir)?;\n\n      let path = cache_storage_dir.join(\"cache_metadata.db\");\n      let connection = rusqlite::Connection::open(&path).unwrap_or_else(|_| {\n        panic!(\"failed to open cache db at {}\", path.display())\n      });\n      // Enable write-ahead-logging mode.\n      let initial_pragmas = \"\n        -- enable write-ahead-logging mode\n        PRAGMA journal_mode=WAL;\n        PRAGMA synchronous=NORMAL;\n        PRAGMA optimize;\n      \";\n      connection.execute_batch(initial_pragmas)?;\n      connection\n    };\n\n    connection.execute(\n      \"CREATE TABLE IF NOT EXISTS cache_storage (\n                    id              INTEGER PRIMARY KEY,\n                    cache_name      TEXT NOT NULL UNIQUE\n                )\",\n      (),","sourceCodeStart":94,"sourceCodeEnd":130,"githubUrl":"https://github.com/denoland/deno/blob/9ad36f7a2cce60488e6ec52283efb32efddaf93a/ext/cache/sqlite.rs#L94-L130","documentation":"In the default disk mode, Deno opens a SQLite metadata database (cache_metadata.db plus WAL/SHM sidecar files) inside its cache storage directory (derived from DENO_DIR). This panic means Connection::open failed on that exact path — the directory could not be used or the database file could not be opened or created. The message includes the full path, which tells you which directory is at fault.","triggerScenarios":"DENO_DIR (or the default cache dir) resolving to a read-only location, a permission-denied directory, a full disk, or a corrupted/locked cache_metadata.db left behind by a crashed process. Note the cache dir is also rejected if it is a symlink, which surfaces as an error before this point.","commonSituations":"Running Deno in containers with read-only volumes; ownership mismatches after running Deno under sudo; a previous crashed process leaving a locked or corrupt db; DENO_DIR pointing somewhere unusual in CI.","solutions":["Check the path in the message: ensure the directory exists and is writable (`mkdir -p` + `touch` test)","Delete the named cache_metadata.db and its -wal/-shm siblings so Deno recreates it — it is a rebuildable cache","Fix ownership/permissions if Deno was ever run under sudo or another user","Point DENO_DIR at a known-writable location, e.g. `DENO_DIR=$HOME/.cache/deno`"],"exampleFix":"# before — unwritable cache dir\nDENO_DIR=/read-only/cache deno run app.ts\n\n# after — clear a corrupt db and use a writable dir\nrm -f \"$HOME/.cache/deno/cache_metadata.db\"*\nDENO_DIR=$HOME/.cache/deno deno run app.ts","handlingStrategy":"fallback","validationCode":"# verify the cache dir is usable before running deno\nCACHE=\"${DENO_DIR:-$HOME/.cache/deno}\"\nmkdir -p \"$CACHE\" && touch \"$CACHE/cache_metadata.db\" && rm \"$CACHE/cache_metadata.db\" \\\n  || echo \"cache dir not writable: $CACHE\"","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Keep DENO_DIR on a writable filesystem owned by the same user that runs Deno","Delete cache_metadata.db plus -wal/-shm siblings when corruption is suspected — the cache rebuilds","Never point DENO_DIR at a symlinked or read-only volume; keep one DENO_DIR per user/container"],"tags":["sqlite","cache","filesystem","permissions","deno-dir"],"backgroundTag":"sqlite-open-failed","analyzedSha":"9ad36f7a2cce60488e6ec52283efb32efddaf93a","analyzedAt":"2026-08-20T13:07:44.778Z","schemaVersion":2},"datasetVersion":"2026-08-31T14:17:45.589Z"}