{"record":{"id":"d0bb2230c0554ce2","repo":"abhigyanpatwari/GitNexus","slug":"no-gitnexus-index-found-for-repopath-run-gitnexus-analyze","errorCode":null,"errorMessage":"No GitNexus index found for ${repoPath}. Run gitnexus analyze first.","messagePattern":"No GitNexus index found for (.+?)\\. Run gitnexus analyze first\\.","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"gitnexus/src/cli/embeddings-sync.ts","lineNumber":56,"sourceCode":"} from '../core/embeddings/runtime-support.js';\nimport { reapEmbeddingSidecarSafely } from '../core/embeddings/embedding-sidecar-reap.js';\n\n/** Add missing embeddings directly to a healthy index, checkpointing periodically. */\nexport const embeddingsSyncCommand = async (inputPath?: string): Promise<void> => {\n  const repoPath = inputPath ? path.resolve(inputPath) : getGitRoot(process.cwd());\n  if (!repoPath) throw new Error('Not inside a git repository. Pass a repository path.');\n\n  const { lbugPath, metaPath } = getStoragePaths(repoPath);\n  const metaDir = path.dirname(metaPath);\n  const lock = await acquireIndexLock(metaDir);\n  try {\n    requireExclusiveIndexLock(\n      lock,\n      `Cannot acquire the index lock at ${metaDir}; refusing an unlocked embeddings sync.`,\n    );\n    const meta = await loadMeta(metaDir);\n    if (!meta)\n      throw new Error(`No GitNexus index found for ${repoPath}. Run gitnexus analyze first.`);\n    if (meta.incrementalInProgress) {\n      throw new Error('The structural index is incomplete. Run gitnexus analyze --force first.');\n    }\n\n    let lbugStat;\n    try {\n      lbugStat = await lstat(lbugPath);\n    } catch {\n      throw new Error(\n        `The LadybugDB graph store at ${lbugPath} is missing. Run gitnexus analyze first.`,\n      );\n    }\n    if (!lbugStat.isFile()) {\n      throw new Error(\n        `The LadybugDB graph store at ${lbugPath} is not a usable database file. Run gitnexus analyze first.`,\n      );\n    }\n","sourceCodeStart":38,"sourceCodeEnd":74,"githubUrl":"https://github.com/abhigyanpatwari/GitNexus/blob/ac9a4e9abd8fd3058c070b72c23402a4f887929a/gitnexus/src/cli/embeddings-sync.ts#L38-L74","documentation":"After acquiring the index lock, the sync loads the index metadata file. If loadMeta returns null there is no GitNexus index metadata for the resolved repo path, meaning `gitnexus analyze` has never been run (or the metadata file was deleted). Sync needs an existing healthy index to add embeddings to.","triggerScenarios":"Running embeddings sync against a repo with no `.gitnexus/` metadata file — first run on a fresh clone, after `gitnexus clean`, after manually deleting the index directory, or pointing the command at the wrong repo path.","commonSituations":"Fresh clone where the index was never generated; CI container where only the source was checked out; running the command in a sibling directory with a similar name.","solutions":["Run `gitnexus analyze` in the repository first, then re-run the embeddings sync.","Confirm the metadata exists: check for `.gitnexus/` (or your GITNEXUS_STORAGE_PATH) in the repo root.","Make sure you are pointing at the correct repository path if you passed one explicitly.","If metadata was deleted accidentally, restore from backup or rebuild via analyze."],"exampleFix":"// before\n$ gitnexus embeddings-sync .   # Error: No GitNexus index found\n// after\n$ gitnexus analyze\n$ gitnexus embeddings-sync .","handlingStrategy":"validation","validationCode":"import { existsSync } from 'node:fs';\nimport { join } from 'node:path';\nfunction hasGitNexusIndex(repoPath) {\n  return existsSync(join(repoPath, '.gitnexus'));\n}\nif (!hasGitNexusIndex(repo)) await run('gitnexus analyze');","typeGuard":null,"tryCatchPattern":"try {\n  await gitnexus.embeddingsSync(repo);\n} catch (err) {\n  if (err.message.includes('No GitNexus index found')) {\n    await run('gitnexus analyze');\n    await gitnexus.embeddingsSync(repo); // retry once after indexing\n  } else throw err;\n}","preventionTips":["Always run `gitnexus analyze` before embeddings sync on a fresh clone or clean checkout.","Remember .gitnexus/ is local (typically gitignored) — it does not survive fresh clones.","In CI, add an index-creation step before any embeddings work.","Double-check GITNEXUS_STORAGE_PATH points at the directory containing the index you intend to sync."],"tags":["index","embeddings","missing-metadata"],"backgroundTag":"file-not-found","analyzedSha":"ac9a4e9abd8fd3058c070b72c23402a4f887929a","analyzedAt":"2026-09-15T23:29:44.066Z","contentChangedAt":"2026-09-15T23:29:44.066Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}