abhigyanpatwari/GitNexus · error

No indexed repositories. Run: gitnexus analyze

Error message

No indexed repositories. Run: gitnexus analyze

What it means

During repo resolution, a cache miss triggers a registry refresh and one retry; if the retry still misses and the registry contains zero repos, LocalBackend throws this bootstrap hint instead of a not-found list. It means the GitNexus registry on this machine has never had a repo indexed (or points at an empty/alternate registry location).

Solutions

  1. Run `gitnexus analyze` in the repository you want indexed, then retry the tool call.
  2. Confirm the repo appears: run the list_repos tool or `gitnexus status`.
  3. Check that GITNEXUS-related home/registry env vars are unset or consistently set in both the indexing shell and the MCP client environment.
  4. Restart the MCP server/session after indexing so it picks up the refreshed registry.

Example fix

# before: no repo indexed yet
$ gitnexus mcp call query '{"search_query": "auth flow"}'
# → No indexed repositories. Run: gitnexus analyze

# after: index first, then query
$ cd ~/code/myrepo && gitnexus analyze
$ gitnexus mcp call query '{"search_query": "auth flow", "repo": "myrepo"}'
Defensive patterns

Strategy: validation

Validate before calling

// Preflight: ensure at least one repo is registered before repo-scoped calls
const repos = await client.callTool({ name: 'list_repos', arguments: {} });
if (!repos?.repositories?.length) {
  throw new Error('No repos indexed yet — run `gitnexus analyze` in the target repo first');
}

Try / catch

try {
  return await client.callTool({ name: 'query', arguments: args });
} catch (err) {
  if (err instanceof Error && err.message.includes('No indexed repositories')) {
    // bootstrap state, not a bug: index the repo, then retry once
    await run('gitnexus analyze', { cwd: targetRepo });
    return client.callTool({ name: 'query', arguments: { ...args, repo: targetRepoName } });
  }
  throw err;
}

Prevention

When it happens

Trigger: Calling any repo-scoped MCP tool (query, context, impact, ...) on a fresh install before any `gitnexus analyze` has run; after wiping the registry directory; or with GITNEXUS home/registry env overrides pointing at a different, empty location than the one you indexed into.

Common situations: First-time users wiring an MCP client before their first analyze; CI containers starting from a clean image each run; switching between global and npx installs that use different registry paths; env-var experiments leaving stale overrides set.

Related errors


AI-assisted analysis of abhigyanpatwari/GitNexus@ac9a4e9abd (2026-08-20). Data as JSON: /api/errors/6f8fc08a4a018945. Report an issue: GitHub.

Appendix: source

Thrown at gitnexus/src/mcp/local/local-backend.ts:1941

    };
    // Record the assignment so subsequent entries in the same refresh see this
    // id as taken (the function owns its own invariant).
    const claim = (id: string): string => {
      assigned.set(id, resolved);
      return id;
    };

    if (free(base)) return claim(base);

    // Legacy suffix from the *raw* path — kept byte-for-byte so the first
    // colliding duplicate keeps the id it had before #2054 (#1658 tier).
    const legacy = `${base}-${Buffer.from(repoPath)
      .toString('base64url')
      .slice(0, REPO_ID_HASH_LENGTH)
      .toLowerCase()}`;
    if (free(legacy)) return claim(legacy);

    // Real collision — hash the resolved path. Lowercase hex survives the
    // `paramLower` lookup in resolveRepoFromCache.
    const digest = createHash('sha256').update(resolved).digest('hex');
    for (let len = REPO_ID_HASH_LENGTH; len <= digest.length; len++) {
      const candidate = `${base}-${digest.slice(0, len)}`;
      if (free(candidate)) return claim(candidate);
    }

    // Two distinct resolved paths sharing a full SHA-256 digest is a hash
    // break, not a runtime condition — fail loudly rather than silently
    // overwrite a different repo's handle (#2054 invariant).
    throw new Error(
      `GitNexus internal: unable to assign a unique repo id for "${name}" at ${repoPath}`,
    );
  }

  // ─── Repo Resolution ─────────────────────────────────────────────

  /**

View on GitHub (pinned to ac9a4e9abd)