{"record":{"id":"4542a92b9e11cdec","repo":"dmtrKovalenko/fff","slug":"failed-to-init-frecency-db","errorCode":null,"errorMessage":"Failed to init frecency db: {}","messagePattern":"Failed to init frecency db: (.+?)","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/fff-c/src/lib.rs","lineNumber":225,"sourceCode":"    let frecency_path = unsafe { optional_cstr(opts.frecency_db_path) }.map(|s| s.to_string());\n    let history_path = unsafe { optional_cstr(opts.history_db_path) }.map(|s| s.to_string());\n\n    let shared_picker = SharedFilePicker::default();\n    let shared_frecency = SharedFrecency::default();\n    let query_tracker = SharedQueryTracker::default();\n\n    if let Some(ref frecency_path) = frecency_path {\n        if let Some(parent) = PathBuf::from(frecency_path).parent() {\n            let _ = std::fs::create_dir_all(parent);\n        }\n\n        match FrecencyTracker::open(frecency_path) {\n            Ok(tracker) => {\n                if let Err(e) = shared_frecency.init(tracker) {\n                    return FffResult::err(&format!(\"Failed to acquire frecency lock: {}\", e));\n                }\n            }\n            Err(e) => return FffResult::err(&format!(\"Failed to init frecency db: {}\", e)),\n        }\n    }\n\n    if let Some(ref history_path) = history_path {\n        if let Some(parent) = PathBuf::from(history_path).parent() {\n            let _ = std::fs::create_dir_all(parent);\n        }\n\n        match QueryTracker::open(history_path) {\n            Ok(tracker) => {\n                if let Err(e) = query_tracker.init(tracker) {\n                    return FffResult::err(&format!(\"Failed to acquire query tracker lock: {}\", e));\n                }\n            }\n            Err(e) => return FffResult::err(&format!(\"Failed to init query tracker db: {}\", e)),\n        }\n    }\n","sourceCodeStart":207,"sourceCodeEnd":243,"githubUrl":"https://github.com/dmtrKovalenko/fff/blob/7f8537e70f0ea1210f9acbbfc4640141105cdc78/crates/fff-c/src/lib.rs#L207-L243","documentation":"FrecencyTracker::open failed to open or create the LMDB frecency database at frecency_db_path. The LMDB error is embedded in the message. Without the frecency db, ranking data cannot load, so instance creation fails.","triggerScenarios":"frecency_db_path points to a non-existent, unwritable directory; the db file is corrupted or locked by another process; parent directory creation failed; invalid path syntax.","commonSituations":"Read-only home/cache directories (containers, CI); a stale or corrupted data.mdb/lock.mdb after a crash; two different library versions sharing one db file; full disk.","solutions":["Ensure the directory for frecency_db_path exists and is writable (library creates parents but check permissions).","Delete the corrupted LMDB files (data.mdb/lock.mdb) so they are recreated — frecency data is rebuildable cache.","Stop other processes holding the db lock, then retry.","Point frecency_db_path at a fresh writable location to confirm it is a path/permission issue.","Check free disk space."],"exampleFix":"// before\nopts.frecency_db_path = \"/root/.cache/fff/frecency\"; // no permission\n// after\nopts.frecency_db_path = \"/home/me/.cache/fff/frecency\"; // or rm corrupted *.mdb files","handlingStrategy":"fallback","validationCode":"const fs = require('fs');\nif (frecencyPath) { fs.mkdirSync(path.dirname(frecencyPath), { recursive: true }); fs.accessSync(path.dirname(frecencyPath), fs.constants.W_OK); }","typeGuard":null,"tryCatchPattern":"try {\n  createInstance({ ...opts, frecency_db_path: p });\n} catch (e) {\n  if (/Failed to init frecency db/.test(e.message)) {\n    fs.rmSync(p, { recursive: true, force: true }); // clear corrupt LMDB cache\n    return createInstance({ ...opts, frecency_db_path: p });\n  }\n  throw e;\n}","preventionTips":["Keep frecency db in a writable per-user cache dir.","Do not share one db path across app versions/processes.","Treat the db as rebuildable cache; safe to delete on corruption.","Monitor disk space in long-running environments."],"tags":["lmdb","database","rust","file-io"],"backgroundTag":"database-query-failed","analyzedSha":"7f8537e70f0ea1210f9acbbfc4640141105cdc78","analyzedAt":"2026-09-10T07:26:53.407Z","contentChangedAt":"2026-09-10T07:26:53.407Z","schemaVersion":2},"datasetVersion":"2026-09-16T09:17:16.951Z"}