{"record":{"id":"7becda0ac4afadfd","repo":"LykosAI/StabilityMatrix","slug":"pip-show-failed-with-code-result-exitcode-result-7becda","errorCode":null,"errorMessage":"pip show failed with code {result.ExitCode}: {result.StandardOutput}, {result.StandardError}","messagePattern":"pip show failed with code (.+?): (.+?), (.+?)","errorType":"exception","errorClass":"ProcessException","httpStatus":null,"severity":"error","filePath":"StabilityMatrix.Core/Python/UvVenvRunner.cs","lineNumber":394,"sourceCode":"                EnvironmentVariables\n            )\n            .ConfigureAwait(false);\n\n        var packageNotFound =\n            result.StandardOutput?.Contains(\"Package(s) not found\", StringComparison.OrdinalIgnoreCase)\n                == true\n            || result.StandardError?.Contains(\"Package(s) not found\", StringComparison.OrdinalIgnoreCase)\n                == true;\n\n        if (packageNotFound)\n        {\n            return null;\n        }\n\n        // Check return code\n        if (result.ExitCode != 0)\n        {\n            throw new ProcessException(\n                $\"pip show failed with code {result.ExitCode}: {result.StandardOutput}, {result.StandardError}\"\n            );\n        }\n\n        if (string.IsNullOrWhiteSpace(result.StandardOutput))\n        {\n            throw new ProcessException(\n                $\"pip show returned no output for package '{packageName}': {result.StandardError}\"\n            );\n        }\n\n        return PipShowResult.Parse(result.StandardOutput);\n    }\n\n    /// <summary>\n    /// Run a pip index command, return result as PipIndexResult.\n    /// </summary>\n    public async Task<PipIndexResult?> PipIndex(","sourceCodeStart":376,"sourceCodeEnd":412,"githubUrl":"https://github.com/LykosAI/StabilityMatrix/blob/af93d6ef57c01cd890d7e0ad0a9ea8c9fcda3002/StabilityMatrix.Core/Python/UvVenvRunner.cs#L376-L412","documentation":"UvVenvRunner.PipShow runs `uv pip show <package>` against the venv and throws this ProcessException when the process exits with a non-zero code and the output does not contain the handled \"Package(s) not found\" marker. It wraps the pip/uv subprocess failure (including its stdout and stderr) so callers get the underlying pip diagnostics instead of a raw exit code. It means the query itself failed — e.g. uv could not talk to the environment — not merely that the package is absent.","triggerScenarios":"Calling UvVenvRunner.PipShow(packageName) where `uv pip show --python <venvPython>` exits non-zero for a reason other than \"Package(s) not found\": a corrupt or missing venv python, an invalid/unreachable --index/--python configuration, or uv crashing before producing a show result.","commonSituations":"The venv's python interpreter was deleted or upgraded out from under the venv; the uv executable is a mismatched version; environment variables or a custom index passed to the runner break the command; disk/permission problems inside the venv cause pip internals to fail.","solutions":["Read the StandardOutput/StandardError embedded in the message to identify the underlying pip/uv failure and fix that cause.","Verify the venv is intact: check that PythonPath exists and `uv pip show` runs manually against the same interpreter.","Recreate the venv (e.g. UvVenvRunner.SetupUvVenv / delete and re-setup) if the interpreter or site-packages are broken.","Confirm the uv executable version matches expectations (File.Exists(UvExecutablePath) passed, but the binary may be stale) and update it."],"exampleFix":"// before: assuming null means 'not installed' for every failure\nvar info = await runner.PipShow(packageName);\n// after: catch and distinguish 'not installed' (null) from a real pip failure\nPipShowResult? info;\ntry { info = await runner.PipShow(packageName); }\ncatch (ProcessException ex) {\n    Logger.Error($\"pip show failed for {packageName}: {ex.Message}\");\n    throw; // not-found is returned as null by PipShow; this is a genuine failure\n}","handlingStrategy":"try-catch","validationCode":"if (!File.Exists(runner.UvExecutablePath)) throw new InvalidOperationException(\"uv missing\");\nif (!File.Exists(runner.PythonPath)) throw new InvalidOperationException(\"venv python missing\");","typeGuard":"static bool VenvUsable(UvVenvRunner r) => File.Exists(r.UvExecutablePath) && File.Exists(r.PythonPath);","tryCatchPattern":"try { var info = await runner.PipShow(pkg); }\ncatch (ProcessException ex) { Logger.Error(ex.Message); throw; } // null already means 'not installed'","preventionTips":["Remember PipShow returns null for not-found; only exceptions are real failures.","Validate venv health (python + uv exist) before batch querying packages.","Keep uv updated to a version with stable `pip show` behavior."],"tags":["python","pip","process","venv"],"backgroundTag":"command-not-found","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"}