{"record":{"id":"12bd5cbe1434fbda","repo":"LykosAI/StabilityMatrix","slug":"venv-creation-failed-with-code-venvproc-exitcode-12bd5c","errorCode":null,"errorMessage":"Venv creation failed with code {venvProc.ExitCode}","messagePattern":"Venv creation failed with code (.+?)","errorType":"exception","errorClass":"ProcessException","httpStatus":null,"severity":"error","filePath":"StabilityMatrix.Core/Python/UvVenvRunner.cs","lineNumber":173,"sourceCode":"            \"--python\",\n            BaseInstall.PythonExePath\n        );\n\n        var venvProc = ProcessRunner.StartAnsiProcess(\n            UvExecutablePath,\n            args.ToProcessArgs(),\n            WorkingDirectory?.FullPath,\n            onConsoleOutput\n        );\n\n        try\n        {\n            await venvProc.WaitForExitAsync(cancellationToken).ConfigureAwait(false);\n\n            // Check return code\n            if (venvProc.ExitCode != 0)\n            {\n                throw new ProcessException($\"Venv creation failed with code {venvProc.ExitCode}\");\n            }\n        }\n        catch (OperationCanceledException)\n        {\n            venvProc.CancelStreamReaders();\n        }\n        finally\n        {\n            venvProc.Kill();\n            venvProc.Dispose();\n        }\n    }\n\n    /// <summary>\n    /// Set current python path to pyvenv.cfg\n    /// This should be called before using the venv, in case user moves the venv directory.\n    /// </summary>\n    private void SetPyvenvCfg(string pythonDirectory, bool force = false)","sourceCodeStart":155,"sourceCodeEnd":191,"githubUrl":"https://github.com/LykosAI/StabilityMatrix/blob/af93d6ef57c01cd890d7e0ad0a9ea8c9fcda3002/StabilityMatrix.Core/Python/UvVenvRunner.cs#L155-L191","documentation":"Setup() shells out to `uv venv <root> --allow-existing --python <BaseInstall.PythonExePath>`. If that uv process exits with a non-zero code, Setup throws ProcessException noting the exit code. The thrown message does not include uv's stderr, so callers should capture it via the onConsoleOutput callback.","triggerScenarios":"uv venv fails during Setup(): bad/missing --python interpreter path (BaseInstall.PythonExePath not installed), corrupted uv binary, disk/permission errors creating the venv, or cancellation leaving the process dead.","commonSituations":"Embedded Python download incomplete or deleted from LibraryDir; antivirus locking the python.exe; running out of disk space during venv creation; uv asset not downloaded before first Setup call.","solutions":["Ensure the embedded Python (BaseInstall.PythonExePath) is installed and the file exists before Setup()","Attach an onConsoleOutput handler to capture uv's stderr and diagnose the exact failure","Verify the uv executable exists at LibraryDir/Assets/uv and re-download it if corrupt","Check disk space and directory write permissions for RootPath, then retry"],"exampleFix":"// before\nawait venvRunner.Setup();\n// after\nawait venvRunner.Setup(\n    onConsoleOutput: o => logger.LogDebug(\"uv: {Text}\", o.Text),\n    cancellationToken: ct\n);","handlingStrategy":"try-catch","validationCode":"if (!File.Exists(baseInstall.PythonExePath))\n{\n    throw new InvalidOperationException(\"Embedded Python not installed; cannot create venv\");\n}","typeGuard":null,"tryCatchPattern":"try\n{\n    await venvRunner.Setup(onConsoleOutput: o => logger.LogDebug(\"uv: {Text}\", o.Text));\n}\ncatch (ProcessException e)\n{\n    logger.LogError(e, \"uv venv failed\");\n    // surface captured uv output to the user / retry after repair\n}","preventionTips":["Verify BaseInstall.PythonExePath exists before Setup","Always attach onConsoleOutput to capture uv stderr","Ensure uv asset is present and disk has free space","Retry setup after repairing the embedded Python install"],"tags":["python","uv","process","venv"],"backgroundTag":"git-command-failed","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"}