abhigyanpatwari/GitNexus · error

( ) [This index was written by a different @ladybugdb/core…

Error message

${STORAGE_VERSION_MISMATCH_SUGGESTION} (${msg}) [This index was written by a different @ladybugdb/core build (a different storage version) than the one currently installed. Run `gitnexus analyze --force` on this repo to rebuild it with the current engine.]

What it means

throwIfStorageVersionMismatch detects that a LadybugDB error is a storage-version mismatch — the index was written by a different @ladybugdb/core build than the one currently installed — and throws a rebuild-hint Error wrapping the original message. It is called by runSchemaCreationQueries and doInitLbug when opening an existing index.

Solutions

  1. Run `gitnexus analyze --force` on the repo to rebuild the index with the current engine.
  2. Alternatively delete the stored index (<repo>/.gitnexus/) and re-run `gitnexus analyze`.
  3. If the old engine version is required, reinstall the matching @ladybugdb/core build instead of rebuilding.
Defensive patterns

Strategy: try-catch

Try / catch

try {
  await initLbug(dbPath);
} catch (err) {
  try { throwIfStorageVersionMismatch(err); } catch (rebuildHint) {
    console.error('Index built by a different engine; run: gitnexus analyze --force');
    process.exitCode = 1;
  }
  throw err;
}

Prevention

When it happens

Trigger: Opening a repo whose on-disk index was created by an older/newer @ladybugdb/core (e.g. after upgrading the gitnexus npm package or a lockfile bump changed the engine version) during init or schema-creation queries.

Common situations: Upgrading GitNexus and re-running analyze/serve against an old .gitnexus index; switching branches where package.json pins a different @ladybugdb/core; CI caching an index across engine upgrades.

Related errors


AI-assisted analysis of abhigyanpatwari/GitNexus@ac9a4e9abd (2026-09-15). Data as JSON: /api/errors/dafa22bda089b987. Report an issue: GitHub.

Appendix: source

Thrown at gitnexus/src/core/lbug/lbug-config.ts:586

 *  newer engine, opened after downgrading the pinned dependency. Example:
 *  "Runtime exception: Trying to read a database file with a different
 *  version. Database file version: 43, Current build storage version: 42" */
const STORAGE_VERSION_MISMATCH_RE = /database file with a different version/i;

export const STORAGE_VERSION_MISMATCH_SUGGESTION =
  'This index was written by a different @ladybugdb/core build (a different storage version) than the one currently installed. Run `gitnexus analyze --force` on this repo to rebuild it with the current engine.';

export function isStorageVersionMismatchError(err: unknown): boolean {
  if (!err) return false;
  const msg = err instanceof Error ? err.message : String(err);
  return STORAGE_VERSION_MISMATCH_RE.test(msg);
}

/** Throws the rebuild-hint Error when `err` is a storage-version mismatch. */
export function throwIfStorageVersionMismatch(err: unknown): void {
  if (!isStorageVersionMismatchError(err)) return;
  const msg = err instanceof Error ? err.message : String(err);
  throw new Error(`${STORAGE_VERSION_MISMATCH_SUGGESTION} (${msg})`);
}

// ─── Ladybug WAL checkpoint IO error matchers ───────────────────────────────
//
// Matched against LadybugDB v0.18.0 (see `gitnexus/package.json`
// @ladybugdb/core). Strict regexes encode local_file_system.cpp wording
// verified at that version. Two-tier strategy: strict matchers first so we
// only fire on real checkpoint-rotation shapes; a permissive fallback
// catches future Ladybug message drift so the recovery hint keeps surfacing
// even if upstream wording changes.
//
// From Ladybug native LocalFileSystem exceptions (`local_file_system.cpp`),
// surfaced in Node as:
// "Runtime exception: IO exception: Error renaming file ..."
// "Runtime exception: IO exception: Error removing directory or file ..."
// We only match checkpoint-rotation shapes:
//   - "<db>.wal -> <db>.wal.checkpoint" rename failures
//   - "<db>.wal.checkpoint" remove failures

View on GitHub (pinned to ac9a4e9abd)