LykosAI/StabilityMatrix · error · ProcessException

Venv creation failed with code

Error message

Venv creation failed with code {venvProc.ExitCode}

What it means

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.

Solutions

  1. Ensure the embedded Python (BaseInstall.PythonExePath) is installed and the file exists before Setup()
  2. Attach an onConsoleOutput handler to capture uv's stderr and diagnose the exact failure
  3. Verify the uv executable exists at LibraryDir/Assets/uv and re-download it if corrupt
  4. Check disk space and directory write permissions for RootPath, then retry

Example fix

// before
await venvRunner.Setup();
// after
await venvRunner.Setup(
    onConsoleOutput: o => logger.LogDebug("uv: {Text}", o.Text),
    cancellationToken: ct
);
Defensive patterns

Strategy: try-catch

Validate before calling

if (!File.Exists(baseInstall.PythonExePath))
{
    throw new InvalidOperationException("Embedded Python not installed; cannot create venv");
}

Try / catch

try
{
    await venvRunner.Setup(onConsoleOutput: o => logger.LogDebug("uv: {Text}", o.Text));
}
catch (ProcessException e)
{
    logger.LogError(e, "uv venv failed");
    // surface captured uv output to the user / retry after repair
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Understand the failure class

Background: "git command failed": what it means when a tool shells out to git and git exits non-zero — this error's family across 21 libraries.

Related errors


AI-assisted analysis of LykosAI/StabilityMatrix@af93d6ef57 (2026-09-12). Data as JSON: /api/errors/12bd5cbe1434fbda. Report an issue: GitHub.

Appendix: source

Thrown at StabilityMatrix.Core/Python/UvVenvRunner.cs:173

            "--python",
            BaseInstall.PythonExePath
        );

        var venvProc = ProcessRunner.StartAnsiProcess(
            UvExecutablePath,
            args.ToProcessArgs(),
            WorkingDirectory?.FullPath,
            onConsoleOutput
        );

        try
        {
            await venvProc.WaitForExitAsync(cancellationToken).ConfigureAwait(false);

            // Check return code
            if (venvProc.ExitCode != 0)
            {
                throw new ProcessException($"Venv creation failed with code {venvProc.ExitCode}");
            }
        }
        catch (OperationCanceledException)
        {
            venvProc.CancelStreamReaders();
        }
        finally
        {
            venvProc.Kill();
            venvProc.Dispose();
        }
    }

    /// <summary>
    /// Set current python path to pyvenv.cfg
    /// This should be called before using the venv, in case user moves the venv directory.
    /// </summary>
    private void SetPyvenvCfg(string pythonDirectory, bool force = false)

View on GitHub (pinned to af93d6ef57)