{"record":{"id":"942524214827d141","repo":"abhigyanpatwari/GitNexus","slug":"not-inside-a-git-repository-pass-a-repository-path","errorCode":null,"errorMessage":"Not inside a git repository. Pass a repository path.","messagePattern":"Not inside a git repository\\. Pass a repository path\\.","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"gitnexus/src/cli/embeddings-sync.ts","lineNumber":44,"sourceCode":"  persistedEmbeddingCountOrUndefined,\n} from '../core/embedding-count.js';\nimport { isHttpMode } from '../core/embeddings/http-client.js';\nimport {\n  ANALYZE_EMBEDDING_INSTALL_TIMEOUT_MS,\n  getEmbeddingInstallTimeoutMs,\n  getEmbeddingRuntimeDir,\n  installEmbeddingRuntime,\n} from '../core/embeddings/runtime-install.js';\nimport {\n  assessLocalEmbeddingRuntime,\n  localEmbeddingStackMissingMessage,\n} 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 {","sourceCodeStart":26,"sourceCodeEnd":62,"githubUrl":"https://github.com/abhigyanpatwari/GitNexus/blob/ac9a4e9abd8fd3058c070b72c23402a4f887929a/gitnexus/src/cli/embeddings-sync.ts#L26-L62","documentation":"embeddingsSyncCommand resolves the repository as either the explicit inputPath or the current git root (getGitRoot(process.cwd())). When neither yields a repository — getGitRoot returns null and no path was passed — it refuses to proceed because it cannot determine where the index lives.","triggerScenarios":"Running the embeddings sync command from a directory that is not inside any git work tree (e.g. $HOME, /tmp, a bare non-repo folder) without passing a repository path argument.","commonSituations":"Running the command from an un-initialized folder where someone forgot `git init`, running it from a parent directory outside the repo, or shell cwd pointing at a deleted/renamed work tree.","solutions":["cd into your git repository before running the command.","Pass the repository path explicitly, e.g. `gitnexus embeddings-sync /path/to/repo`.","If the folder should be a repo, run `git init` (and commit) first; GitNexus requires a git root.","Verify getGitRoot would succeed: `git rev-parse --show-toplevel` from the same directory."],"exampleFix":"// before\n$ cd /tmp && gitnexus embeddings-sync\n// after\n$ cd /tmp/my-repo && gitnexus embeddings-sync\n// or\n$ gitnexus embeddings-sync /tmp/my-repo","handlingStrategy":"validation","validationCode":"import { execSync } from 'node:child_process';\nfunction insideGitRepo(dir = process.cwd()) {\n  try { execSync('git rev-parse --show-toplevel', { cwd: dir, stdio: 'ignore' }); return true; }\n  catch { return false; }\n}\nif (!insideGitRepo()) process.chdir(REPO_PATH); // or pass the path to the command","typeGuard":null,"tryCatchPattern":"try {\n  await gitnexus.embeddingsSync(repoPath);\n} catch (err) {\n  if (err.message.includes('Not inside a git repository')) {\n    console.error('Run from a git work tree or pass the repo path.');\n  } else throw err;\n}","preventionTips":["Run GitNexus commands from the repository root or pass the repo path explicitly in scripts/CI.","Add `git rev-parse --show-toplevel` as a precondition check in wrapper scripts.","Ensure `git init` has been run in new workspaces before indexing.","Avoid cd-ing outside the work tree in shell scripts that invoke the CLI."],"tags":["git","cli","working-directory"],"backgroundTag":"directory-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"}