LykosAI/StabilityMatrix · error · ProcessException

Process failed with exit-code .

Error message

Process {processName} failed with exit-code {process.ExitCode}.

What it means

ProcessRunner.WaitForExitConditionAsync throws ProcessException when the spawned process exits with a non-success (non-zero) exit code. It includes the process name and exit code to identify which external tool failed.

Solutions

  1. Read the process's captured stdout/stderr output to see the underlying error message.
  2. Re-run the command manually in a terminal to reproduce and diagnose.
  3. Fix the environment the process runs in (dependencies, paths, permissions).
  4. Handle ProcessException in the caller and surface process output to the user.
  5. Ensure ProcessStartInfo redirects output so diagnostics are available.

Example fix

// before
await processRunner.WaitForExitConditionAsync(process); // throws on non-zero exit
// after
try
{
    await processRunner.WaitForExitConditionAsync(process);
}
catch (ProcessException ex)
{
    _logger.LogError("Process failed: {Message}\nStderr: {Stderr}", ex.Message, processOutput.Stderr);
    throw;
}
Defensive patterns

Strategy: try-catch

Validate before calling

// Verify the executable and environment before launching
if (!File.Exists( exePath )) throw new FileNotFoundException("Executable missing", exePath);
if (process.StartInfo.RedirectStandardError == false)
    process.StartInfo.RedirectStandardError = true; // ensure diagnostics are captured

Try / catch

try { await processRunner.WaitForExitConditionAsync(process); }
catch (ProcessException ex)
{
    _logger.LogError(ex, "Process exited with code {Code}; stderr: {Stderr}",
        process.ExitCode, stderrBuilder.ToString());
    throw;
}

Prevention

When it happens

Trigger: Any child process launched and awaited via ProcessRunner (e.g. python, pip, git, model tools) terminating with a non-zero exit code.

Common situations: Missing Python packages, script exceptions, insufficient permissions, bad CLI arguments, out-of-disk during model operations, incompatible environment versions.

Related errors


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

Appendix: source

Thrown at StabilityMatrix.Core/Processes/ProcessRunner.cs:696

        if (!process.HasExited)
        {
            await process.WaitForExitAsync(cancelToken).ConfigureAwait(false);
        }

        if (process.ExitCode == expectedExitCode)
        {
            return;
        }

        // Accessing ProcessName may error on some platforms
        string? processName = null;
        try
        {
            processName = process.ProcessName;
        }
        catch (SystemException) { }

        throw new ProcessException(
            "Process "
                + (processName == null ? "" : processName + " ")
                + $"failed with exit-code {process.ExitCode}."
        );
    }
}

View on GitHub (pinned to af93d6ef57)