LykosAI/StabilityMatrix · error · InvalidOperationException

Package not found or not installed correctly

Error message

Package not found or not installed correctly

What it means

StableSwarm's 'Rebuild .NET Project' extra command throws InvalidOperationException when installedPackage is null or FullPath is empty — the same guard pattern as other packages, ensuring the rebuild only runs on a real installation directory.

Solutions

  1. Reinstall StableSwarm so its FullPath is correctly recorded, then rerun the rebuild command.
  2. Verify the SwarmUI folder (with src/) exists at FullPath; move it back or reinstall if missing.
  3. Delete the stale package entry and reinstall fresh.
  4. Ensure the dotnet prerequisite is installed before rebuilding.
Defensive patterns

Strategy: type-guard

Validate before calling

if (installedPackage is not { FullPath: { Length: > 0 } } || !Directory.Exists(installedPackage.FullPath))
{
    // reinstall SwarmUI before attempting the rebuild
}

Type guard

bool CanRebuild(InstalledPackage? p) => p is { FullPath: { Length: > 0 } } && Directory.Exists(p.FullPath);

Try / catch

try { await rebuildCommand(installedPackage); }
catch (InvalidOperationException ex) when (ex.Message == "Package not found or not installed correctly")
{ PromptReinstallSwarm(); }

Prevention

When it happens

Trigger: Running the rebuild extra command against a null package reference or a package whose FullPath is unset (failed/removed install, stale record).

Common situations: SwarmUI entry left after a failed install or folder move; invoking the command from a stale UI session; library directory relocated without updating the database.

Understand the failure class

Background: "Not found" and "does not exist" errors: why "Task not found", "No such folder", and "Can't find" fire when a lookup comes back empty — this error's family across 14 libraries.

Related errors


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

Appendix: source

Thrown at StabilityMatrix.Core/Models/Packages/StableSwarm.cs:71

    public override Uri PreviewImageUri =>
        new("https://github.com/mcmonkeyprojects/SwarmUI/raw/master/.github/images/swarmui.jpg");
    public override string OutputFolderName => "Output";
    public override IEnumerable<SharedFolderMethod> AvailableSharedFolderMethods =>
        [SharedFolderMethod.Symlink, SharedFolderMethod.Configuration, SharedFolderMethod.None];
    public override SharedFolderMethod RecommendedSharedFolderMethod => SharedFolderMethod.Configuration;
    public override bool OfferInOneClickInstaller => false;
    public override bool UsesVenv => false;

    public override List<ExtraPackageCommand> GetExtraCommands() =>
        [
            new()
            {
                CommandName = "Rebuild .NET Project",
                Command = async installedPackage =>
                {
                    if (installedPackage == null || string.IsNullOrEmpty(installedPackage.FullPath))
                    {
                        throw new InvalidOperationException("Package not found or not installed correctly");
                    }

                    var srcFolder = Path.Combine(installedPackage.FullPath, "src");
                    var csprojName = "StableSwarmUI.csproj";
                    if (File.Exists(Path.Combine(srcFolder, "SwarmUI.csproj")))
                    {
                        csprojName = "SwarmUI.csproj";
                    }

                    await RebuildDotnetProject(installedPackage.FullPath, csprojName, null)
                        .ConfigureAwait(false);
                },
            },
        ];

    public override List<LaunchOptionDefinition> LaunchOptions =>
        [
            new LaunchOptionDefinition

View on GitHub (pinned to af93d6ef57)