LykosAI/StabilityMatrix · error · InvalidOperationException

Install script failed with exit code

Error message

Install script failed with exit code {exitCode}

What it means

ForgeClassic.InstallPackage throws InvalidOperationException when the venv-launched install script (pip/requirements setup) finishes with a nonzero exit code. It signals the installation script failed partway and the package should be considered not correctly installed.

Solutions

  1. Scroll back in the install log for the actual pip error; fix that root cause (network, disk space, dependency conflict) and reinstall.
  2. Retry the install after deleting the package's venv so a clean environment is created.
  3. Choose a different Python version for the package (e.g. 3.10/3.11) if the requirements fail to resolve.
  4. Check disk space and proxy/firewall settings that may block package downloads.
Defensive patterns

Strategy: try-catch

Validate before calling

// verify disk space, network reachability, and chosen python version before InstallPackage
if (!HasEnoughDiskSpace(installLocation, requiredGb: 10)) return;

Try / catch

try { await package.InstallPackage(...); }
catch (InvalidOperationException ex) when (ex.Message.StartsWith("Install script failed"))
{ ShowInstallLogAndOfferRetry(); }

Prevention

When it happens

Trigger: InstallPackage runs the install script via RunInstallScriptWithPromptHandling; the detached process exits with exitCode != 0 (pip resolution failure, network error, missing requirements, python version incompatibility).

Common situations: PyTorch/dependency wheels fail to download; requirements pin incompatible with the chosen Python version; antivirus or file locks interrupt the venv writes.

Related errors


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

Appendix: source

Thrown at StabilityMatrix.Core/Models/Packages/ForgeClassic.cs:279

                onConsoleOutput?.Invoke(
                    ProcessOutput.FromStdOutLine(
                        "[ForgeClassic] Retrying install after backing up legacy config files..."
                    )
                );

                exitCode = await RunInstallScriptWithPromptHandling(
                        venvRunner,
                        launchArgs,
                        onConsoleOutput,
                        cancellationToken
                    )
                    .ConfigureAwait(false);
            }
        }

        if (exitCode != 0)
        {
            throw new InvalidOperationException($"Install script failed with exit code {exitCode}");
        }

        if (
            !string.Equals(
                installedPackage.PythonVersion,
                targetPythonVersion.StringValue,
                StringComparison.Ordinal
            )
        )
        {
            installedPackage.PythonVersion = targetPythonVersion.StringValue;
        }

        progress?.Report(new ProgressReport(1f, "Install complete", isIndeterminate: false));
    }

    private async Task<int> RunInstallScriptWithPromptHandling(
        IPyVenvRunner venvRunner,

View on GitHub (pinned to af93d6ef57)