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).

Source

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

      this.maybeWarnSiblingDrift(result).catch(() => {
        /* best-effort; never throw from resolveRepo */
      });
      return this.applyBranchScope(result, branch);
    }

    // Miss — refresh registry and try once more (skip if already refreshed above)
    if (!refreshedAfterAmbiguity) {
      await this.refreshRepos();
    }
    const retried = this.resolveRepoFromCache(repoParam);
    if (retried) {
      this.maybeWarnSiblingDrift(retried).catch(() => {});
      return this.applyBranchScope(retried, branch);
    }

    // Still no match — throw with helpful message
    if (this.repos.size === 0) {
      throw new Error('No indexed repositories. Run: gitnexus analyze');
    }

    // Build a disambiguated "Available: …" list (#829). When two handles
    // share a name, annotate each colliding label with its path so the
    // caller can actually pick the right one. Single-name entries render
    // identically to pre-#829 output.
    const nameCounts = new Map<string, number>();
    for (const h of this.repos.values()) {
      const key = h.name.toLowerCase();
      nameCounts.set(key, (nameCounts.get(key) ?? 0) + 1);
    }
    const labels = [...this.repos.values()].map((h) =>
      (nameCounts.get(h.name.toLowerCase()) ?? 0) > 1 ? `${h.name} (${h.repoPath})` : h.name,
    );

    if (repoParam) {
      throw new Error(`Repository "${repoParam}" not found. Available: ${labels.join(', ')}`);
    }

View on GitHub (pinned to aac7515d2a)

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@aac7515d2a (2026-08-20). Data as JSON: /api/errors/6f8fc08a4a018945. Report an issue: GitHub.