abhigyanpatwari/GitNexus · error · RuntimeError

Failed to install gitnexus: {result.get('output', '')}

Error message

Failed to install gitnexus: {result.get('output', '')}

What it means

Thrown by _install_gitnexus() in eval/environments/gitnexus_docker.py when `npx gitnexus --version` reports NOT_FOUND and the subsequent `npm install -g gitnexus` (60s timeout) returns non-zero. The message includes npm's output so you can diagnose registry/network/package errors.

Source

Thrown at eval/environments/gitnexus_docker.py:142

            ]
            for cmd in install_cmds:
                result = self.execute({"command": cmd, "timeout": 60})
                if result.get("returncode", 1) != 0:
                    raise RuntimeError(f"Failed to install Node.js: {result.get('output', '')}")
        else:
            logger.info(f"Node.js already available: {output}")

    def _install_gitnexus(self):
        """Install the gitnexus npm package globally."""
        check = self.execute({"command": "npx gitnexus --version 2>/dev/null || echo 'NOT_FOUND'"})
        if "NOT_FOUND" in check.get("output", ""):
            logger.info("Installing gitnexus...")
            result = self.execute({
                "command": "npm install -g gitnexus",
                "timeout": 60,
            })
            if result.get("returncode", 1) != 0:
                raise RuntimeError(f"Failed to install gitnexus: {result.get('output', '')}")

    def _index_repository(self):
        """Run gitnexus analyze on the repo, using cache if available."""
        repo_info = self._get_repo_info()
        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,
        })

View on GitHub (pinned to d540b00184)

Solutions

  1. Pre-install gitnexus in the Docker image: `RUN npm install -g gitnexus` at build time so the eval path is a no-op.
  2. Increase the per-step timeout (currently 60s) — global npm install can exceed it on slow links.
  3. Verify registry connectivity: `docker run --rm <image> bash -lc 'npm ping; npm view gitnexus version'`.
  4. If a corporate npm registry is configured, ensure gitnexus is mirrored there, or override npm_config_registry for the install.
  5. Clear the npm cache (`npm cache clean --force`) or rebuild the image to fix a corrupted cache.

Example fix

# before: install at eval time, 60s cap
result = self.execute({'command': 'npm install -g gitnexus', 'timeout': 60})

# after: raise timeout, and pre-bake in Dockerfile
result = self.execute({'command': 'npm install -g gitnexus', 'timeout': 300})
# Dockerfile: RUN npm install -g gitnexus@<pinned-version>
Defensive patterns

Strategy: validation

Validate before calling

# Preflight: confirm npm registry is reachable from the container
docker run --rm "$IMAGE" bash -lc 'npm ping && npm view gitnexus version'

Type guard

def is_gitnexus_install_failure(exc: RuntimeError) -> bool:
    return 'Failed to install gitnexus' in str(exc)

Try / catch

try:
    env._install_gitnexus()
except RuntimeError as e:
    if is_gitnexus_install_failure(e):
        time.sleep(10)
        env._install_gitnexus()  # one retry for transient registry errors
    else:
        raise

Prevention

When it happens

Trigger: Container has Node but no gitnexus; the global `npm install -g gitnexus` fails (non-zero returncode). Example: npm registry unreachable, 60s timeout exceeded on slow networks, npm cache corruption, or a transient registry 5xx.

Common situations: Eval container with no outbound npm access; npm registry rate-limiting CI (429); slow network blowing the 60s timeout; npm cache broken inside the image; npm config pointing at a private registry that lacks gitnexus.

Related errors


AI-assisted analysis of abhigyanpatwari/GitNexus@d540b00184 (2026-08-12). Data as JSON: /api/errors/dbbdca72ac757d4f. Report an issue: GitHub.