{"record":{"id":"40d038b4bcf83c7e","repo":"abhigyanpatwari/GitNexus","slug":"failed-to-remove-the-ladybugdb-index-files-still","errorCode":null,"errorMessage":"Failed to remove the LadybugDB index files — still present after 5 attempts:\n  - ${survivors}\nThe blocking handle may be another process, a lingering handle from this process's just-closed database, or an antivirus scan — an immediate re-run often succeeds. If it persists, stop any GitNexus MCP or serve process using this repository, add an antivirus exclusion for the GitNexus storage directory, then re-run the analyze.","messagePattern":"Failed to remove the LadybugDB index files — still present after 5 attempts:\n  - (.+?)\nThe blocking handle may be another process, a lingering handle from this process's just-closed database, or an antivirus scan — an immediate re-run often succeeds\\. If it persists, stop any GitNexus MCP or serve process using this repository, add an antivirus exclusion for the GitNexus storage directory, then re-run the analyze\\.","errorType":"exception","errorClass":"LbugWipeError","httpStatus":null,"severity":"error","filePath":"gitnexus/src/core/lbug/lbug-adapter.ts","lineNumber":2383,"sourceCode":"      if (!gone) survivors.push(f);\n    }\n    if (survivors.length === 0) return;\n    if (attempt < HANDLE_RELEASE_PROBE_ATTEMPTS) {\n      await sleep(HANDLE_RELEASE_PROBE_DELAY_MS * attempt);\n    }\n  }\n\n  // Class split (FIX 2): the contentless `.lock` never fails the wipe.\n  const dataSurvivors = survivors.filter((f) => f !== lockPath);\n  if (survivors.includes(lockPath)) {\n    logger.warn(\n      `GitNexus: ${lockPath} is still present after the wipe retries — continuing: the ` +\n        'lock file is contentless and initLbug recreates it; a genuinely held lock will ' +\n        \"surface as the reopen's own lock-busy error.\",\n    );\n  }\n  if (dataSurvivors.length > 0) {\n    throw new LbugWipeError(dataSurvivors);\n  }\n};\n\nexport const isLbugReady = (): boolean => conn !== null && db !== null;\n\n/**\n * Multi-label alternation over exactly the labels that can own embedding\n * rows: EMBEDDABLE_LABELS plus File, which embedding-pipeline.ts embeds as\n * the zero-symbol fallback for text-only repositories (#2454). Reserved\n * keywords are backtick-escaped via {@link escapeTableName}. Probed on\n * @ladybugdb/core 0.18.0 (this shipping review, FIX 4): the full multi-label\n * alternation parses, executes, and deletes exactly the joined rows —\n * replacing the unlabeled `MATCH (n)` that scanned EVERY node table per\n * chunk (BasicBlock-dominated under `--pdg`) when only embeddable labels\n * can match an embedding row. Including File is free for code repositories:\n * they never hold File embedding rows, so the extra label joins nothing.\n */\nconst embeddableLabelMatch = (): string =>","sourceCodeStart":2365,"sourceCodeEnd":2401,"githubUrl":"https://github.com/abhigyanpatwari/GitNexus/blob/d540b00184d71a896261ee02670da9a92d59d8f7/gitnexus/src/core/lbug/lbug-adapter.ts#L2365-L2401","documentation":"Thrown as an LbugWipeError when wipeLbugDbFiles cannot delete all LadybugDB data files (the .db, .wal, .shadow family minus the contentless .lock) after exhausting HANDLE_RELEASE_PROBE_ATTEMPTS retries with linear back-off. The wipe runs during `gitnexus analyze` before recreating the index — if a file handle lingers (another process, antivirus scan, OS handle-release lag), the rm/access probe cycle fails every attempt and survivors remain. The error names the surviving file paths and advises on lock remediation.","triggerScenarios":"Running `gitnexus analyze` while a `gitnexus serve` or MCP process still holds the LadybugDB database open; Windows Defender or another antivirus scanner briefly opening the .wal/.db file for inspection during the wipe window; a non-ASCII path on Windows that causes intermittent fs.access failures; a lingering native Database handle from this same process that was closed in JS but whose OS-level file handle hasn't been released by libuv yet.","commonSituations":"Developer runs `gitnexus analyze` without first stopping a running `gitnexus serve` process that opened the DB read-only via the pool adapter; CI environment where parallel test processes share a storage directory; Windows development where Defender scans newly-created files; containerized environments with overlay filesystems that delay handle release; a crashed previous analyze that left zombie file handles.","solutions":["Stop all GitNexus processes (MCP server, serve, any analyze) using this repository, then re-run `gitnexus analyze` — an immediate re-run often succeeds once the handle clears","On Windows, add an antivirus exclusion for the GitNexus storage directory (typically under .gitnexus/ in the repo root) to prevent Defender from briefly holding file handles","If the surviving file is only the .lock, note that the wipe logic already classifies that as benign (continues with a warning) — this error only fires for data files (.db, .wal, .shadow)","Use `lsof <surviving-file>` (Linux/macOS) or Resource Monitor (Windows) to identify which process holds the handle, then kill it","As a last resort, manually `rm -rf` the surviving files from the .gitnexus/ storage directory, then re-run `gitnexus analyze`"],"exampleFix":null,"handlingStrategy":"retry","validationCode":"// Check if any process holds the DB files before wiping\nimport { access, constants } from 'fs/promises';\nasync function canWipe(lbugPath: string): Promise<boolean> {\n  try {\n    // Try opening for write — if another process holds it, this fails\n    await access(lbugPath, constants.W_OK);\n    return true;\n  } catch {\n    return false;\n  }\n}","typeGuard":null,"tryCatchPattern":"try {\n  await wipeLbugDbFiles(lbugPath);\n} catch (e) {\n  if (e instanceof LbugWipeError) {\n    // Stop all GitNexus processes, add AV exclusion, then retry\n    console.error(`Surviving files: ${e.survivors.join(', ')}`);\n    console.error('Stop all gitnexus serve/MCP processes and re-run analyze.');\n  }\n  throw e;\n}","preventionTips":["Always stop `gitnexus serve` and MCP processes before running `gitnexus analyze`","On Windows, add an antivirus exclusion for the .gitnexus/ directory","Use a pre-analyze script that checks for running GitNexus processes","In CI, ensure only one analyze job runs per repo at a time"],"tags":["ladybugdb","file-lock","wipe","windows","analyze","antivirus"],"backgroundTag":null,"analyzedSha":"d540b00184d71a896261ee02670da9a92d59d8f7","analyzedAt":"2026-08-12T19:50:25.132Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}