{"record":{"id":"a6eca38e7838f93b","repo":"LykosAI/StabilityMatrix","slug":"pip-index-failed-with-code-result-exitcode-result","errorCode":null,"errorMessage":"pip index failed with code {result.ExitCode}: {result.StandardOutput}, {result.StandardError}","messagePattern":"pip index failed with code (.+?): (.+?), (.+?)","errorType":"exception","errorClass":"ProcessException","httpStatus":null,"severity":"error","filePath":"StabilityMatrix.Core/Python/PyVenvRunner.cs","lineNumber":450,"sourceCode":"        var noMatchingDistribution =\n            result.StandardOutput?.Contains(\n                \"No matching distribution found\",\n                StringComparison.OrdinalIgnoreCase\n            ) == true\n            || result.StandardError?.Contains(\n                \"No matching distribution found\",\n                StringComparison.OrdinalIgnoreCase\n            ) == true;\n\n        if (noMatchingDistribution || string.IsNullOrWhiteSpace(result.StandardOutput))\n        {\n            return null;\n        }\n\n        // Check return code\n        if (result.ExitCode != 0)\n        {\n            throw new ProcessException(\n                $\"pip index failed with code {result.ExitCode}: {result.StandardOutput}, {result.StandardError}\"\n            );\n        }\n\n        return PipIndexResult.Parse(result.StandardOutput);\n    }\n\n    /// <summary>\n    /// Run a custom install command. Waits for the process to exit.\n    /// workingDirectory defaults to RootPath.\n    /// </summary>\n    public async Task CustomInstall(ProcessArgs args, Action<ProcessOutput>? outputDataReceived = null)\n    {\n        // Record output for errors\n        var output = new StringBuilder();\n\n        var outputAction =\n            outputDataReceived == null","sourceCodeStart":432,"sourceCodeEnd":468,"githubUrl":"https://github.com/LykosAI/StabilityMatrix/blob/af93d6ef57c01cd890d7e0ad0a9ea8c9fcda3002/StabilityMatrix.Core/Python/PyVenvRunner.cs#L432-L468","documentation":"PipIndex runs `pip index versions <package>` and throws ProcessException when the command exits non-zero. Since pip index is an experimental command and fails hard when the package (or matching distribution) cannot be found, this most often means 'no matching package/version found'.","triggerScenarios":"Calling PipIndex(packageName, prerelease:...) when pip exits non-zero: package not on the configured index, no version matches Python version constraints, or index URL unreachable/misconfigured.","commonSituations":"Querying prerelease-only packages with includePrerelease=false; private index URL not set (indexUrl null) so PyPI lacks the package; corporate network blocking pypi.org; package name typo.","solutions":["Read the stderr in the message; if 'No matching distribution found', verify the package name and that versions exist for your Python version.","Pass a custom indexUrl when the package lives on a private index.","Set includePrerelease=true if only pre-releases exist for the package.","Test connectivity: `venv/bin/python -m pip index versions <pkg> --index-url <url>`."],"exampleFix":"// before\nvar res = venv.PipIndex(\"my-internal-pkg\");\n// after\nvar res = venv.PipIndex(\"my-internal-pkg\", indexUrl: \"https://pypi.mycompany.com/simple\");","handlingStrategy":"try-catch","validationCode":"// Verify reachability of the index before querying\nusing var http = new HttpClient();\nvar resp = await http.GetAsync(indexUrl ?? \"https://pypi.org/simple/\");\nif (!resp.IsSuccessStatusCode) throw new InvalidOperationException(\"package index unreachable\");","typeGuard":null,"tryCatchPattern":"try { return venv.PipIndex(pkg, indexUrl); }\ncatch (ProcessException ex) { Logger.Warn(ex, \"pip index failed for {Pkg}\"); return null; }","preventionTips":["Pass the correct indexUrl for private packages","Set includePrerelease for pre-release-only packages","Handle 'no matching distribution' as a normal 'not available' case"],"tags":["python","pip","package-index","network"],"backgroundTag":"http-error-response","analyzedSha":"af93d6ef57c01cd890d7e0ad0a9ea8c9fcda3002","analyzedAt":"2026-09-12T19:02:43.389Z","contentChangedAt":"2026-09-12T19:02:43.389Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}