abhigyanpatwari/GitNexus · error

Not inside a git repository. Pass a repository path.

Error message

Not inside a git repository. Pass a repository path.

What it means

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.

Solutions

  1. cd into your git repository before running the command.
  2. Pass the repository path explicitly, e.g. `gitnexus embeddings-sync /path/to/repo`.
  3. If the folder should be a repo, run `git init` (and commit) first; GitNexus requires a git root.
  4. Verify getGitRoot would succeed: `git rev-parse --show-toplevel` from the same directory.

Example fix

// before
$ cd /tmp && gitnexus embeddings-sync
// after
$ cd /tmp/my-repo && gitnexus embeddings-sync
// or
$ gitnexus embeddings-sync /tmp/my-repo
Defensive patterns

Strategy: validation

Validate before calling

import { execSync } from 'node:child_process';
function insideGitRepo(dir = process.cwd()) {
  try { execSync('git rev-parse --show-toplevel', { cwd: dir, stdio: 'ignore' }); return true; }
  catch { return false; }
}
if (!insideGitRepo()) process.chdir(REPO_PATH); // or pass the path to the command

Try / catch

try {
  await gitnexus.embeddingsSync(repoPath);
} catch (err) {
  if (err.message.includes('Not inside a git repository')) {
    console.error('Run from a git work tree or pass the repo path.');
  } else throw err;
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


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

Appendix: source

Thrown at gitnexus/src/cli/embeddings-sync.ts:44

  persistedEmbeddingCountOrUndefined,
} from '../core/embedding-count.js';
import { isHttpMode } from '../core/embeddings/http-client.js';
import {
  ANALYZE_EMBEDDING_INSTALL_TIMEOUT_MS,
  getEmbeddingInstallTimeoutMs,
  getEmbeddingRuntimeDir,
  installEmbeddingRuntime,
} from '../core/embeddings/runtime-install.js';
import {
  assessLocalEmbeddingRuntime,
  localEmbeddingStackMissingMessage,
} from '../core/embeddings/runtime-support.js';
import { reapEmbeddingSidecarSafely } from '../core/embeddings/embedding-sidecar-reap.js';

/** Add missing embeddings directly to a healthy index, checkpointing periodically. */
export const embeddingsSyncCommand = async (inputPath?: string): Promise<void> => {
  const repoPath = inputPath ? path.resolve(inputPath) : getGitRoot(process.cwd());
  if (!repoPath) throw new Error('Not inside a git repository. Pass a repository path.');

  const { lbugPath, metaPath } = getStoragePaths(repoPath);
  const metaDir = path.dirname(metaPath);
  const lock = await acquireIndexLock(metaDir);
  try {
    requireExclusiveIndexLock(
      lock,
      `Cannot acquire the index lock at ${metaDir}; refusing an unlocked embeddings sync.`,
    );
    const meta = await loadMeta(metaDir);
    if (!meta)
      throw new Error(`No GitNexus index found for ${repoPath}. Run gitnexus analyze first.`);
    if (meta.incrementalInProgress) {
      throw new Error('The structural index is incomplete. Run gitnexus analyze --force first.');
    }

    let lbugStat;
    try {

View on GitHub (pinned to ac9a4e9abd)