abhigyanpatwari/GitNexus · error · RuntimeError
gitnexus analyze failed: {output[-500:]}
Error message
gitnexus analyze failed: {output[-500:]} What it means
Thrown by _index_repository() in eval/environments/gitnexus_docker.py after running `npx gitnexus analyze . [--skip-embeddings]` inside /testbed: if the command returns non-zero AND the output contains 'error' (case-insensitive) but NOT 'indexed', it raises with the last 500 chars of output. This heuristic avoids raising on analyze runs that printed 'error' as part of a successful 'N files indexed' summary.
Source
Thrown at eval/environments/gitnexus_docker.py:165
cache_key = self._make_cache_key(repo_info)
cache_path = self.cache_dir / cache_key
if cache_path.exists():
logger.info(f"Restoring GitNexus index from cache: {cache_key}")
self._restore_cache(cache_path)
return
logger.info("Running gitnexus analyze...")
skip_flag = "--skip-embeddings" if self.skip_embeddings else ""
result = self.execute({
"command": f"cd /testbed && npx gitnexus analyze . {skip_flag} 2>&1",
"timeout": self.gitnexus_timeout,
})
if result.get("returncode", 1) != 0:
output = result.get("output", "")
if "error" in output.lower() and "indexed" not in output.lower():
raise RuntimeError(f"gitnexus analyze failed: {output[-500:]}")
self._save_cache(cache_path, repo_info)
def _start_eval_server(self):
"""Start the GitNexus eval-server daemon in the background."""
logger.info(
f"Starting eval-server on {self.eval_server_host}:{self.eval_server_port}..."
)
self.execute({
"command": (
f"nohup npx gitnexus eval-server --port {self.eval_server_port} "
f"--host {self.eval_server_host} "
f"--idle-timeout 600 "
f"> /tmp/gitnexus-eval-server.log 2>&1 &"
),
"timeout": 5,
})View on GitHub (pinned to d540b00184)
Solutions
- Read the last 500 chars of output in the message — it names the failing step (grammar build, embedding, parse error).
- Ensure the image has the build toolchain: `apt-get install -y python3 make g++` for source-build fallback, or set GITNEXUS_SKIP_OPTIONAL_GRAMMARS=1.
- Increase container memory if embedding/parse died with a 137/OOM-kill signal.
- Clear a corrupt prior index: `rm -rf .gitnexus` (or run gitnexus clean) before re-running analyze.
- Reproduce locally with `npx gitnexus analyze . --skip-embeddings` on the same /testbed checkout to iterate faster.
Example fix
# before
result = self.execute({'command': f'cd /testbed && npx gitnexus analyze . {skip_flag} 2>&1',
'timeout': self.gitnexus_timeout})
# after: pre-install toolchain in the image and pin gitnexus version
# Dockerfile:
# RUN apt-get update && apt-get install -y python3 make g++
# RUN npm install -g gitnexus@<pin>
result = self.execute({'command': f'cd /testbed && gitnexus analyze . {skip_flag} 2>&1',
'timeout': self.gitnexus_timeout}) Defensive patterns
Strategy: try-catch
Validate before calling
# Preflight: dry-run analyze locally on the same /testbed to surface toolchain issues # Ensure required build tools exist in the image: docker run --rm "$IMAGE" bash -lc 'which python3 make g++ || echo MISSING_TOOLCHAIN' # and clear any stale index: docker run --rm -v "$PWD:/testbed" "$IMAGE" bash -lc 'rm -rf /testbed/.gitnexus'
Type guard
def is_analyze_failure(exc: RuntimeError) -> bool:
return 'gitnexus analyze failed' in str(exc) Try / catch
try:
env._index_repository()
except RuntimeError as e:
if is_analyze_failure(e) and 'Out of memory' in str(e):
env.skip_embeddings = True
env._index_repository() # retry lighter
else:
raise Prevention
- Pre-install python3/make/g++ in the image and pin a gitnexus version.
- Pass --skip-embeddings in eval to avoid the memory-heavy embedding step where possible.
- Run `gitnexus clean` between runs to avoid corrupt-index false errors.
When it happens
Trigger: `npx gitnexus analyze . 2>&1` exits non-zero with an error-looking message (parse failure, OOM, missing language toolchain, permission error, grammar build failure). The raise fires only when 'indexed' is absent from the output.
Common situations: Missing C/C++ toolchain (python3/make/g++) so a required tree-sitter grammar source-builds fail; OOM in a constrained container; permission denied writing the index to .gitnexus/; corrupt prior index; out-of-memory embedding step (use --skip-embeddings in eval); repo with a language whose grammar is optional and skipped incorrectly.
Related errors
- Failed to install Node.js: {result.get('output', '')}
- Failed to install gitnexus: {result.get('output', '')}
- Analyze stopped before running out of memory: ${heapUsedMB}M
- Failed to remove the LadybugDB index files — still present a
- LadybugDB not found at ${dbPath}. Run: gitnexus analyze
AI-assisted analysis of abhigyanpatwari/GitNexus@d540b00184 (2026-08-12).
Data as JSON: /api/errors/a7a29416f257d25a.
Report an issue: GitHub.