{"record":{"id":"e32f26b8311a913e","repo":"LykosAI/StabilityMatrix","slug":"package-not-found-or-not-installed-correctly-stableswarm","errorCode":null,"errorMessage":"Package not found or not installed correctly","messagePattern":"Package not found or not installed correctly","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"StabilityMatrix.Core/Models/Packages/StableSwarm.cs","lineNumber":71,"sourceCode":"    public override Uri PreviewImageUri =>\n        new(\"https://github.com/mcmonkeyprojects/SwarmUI/raw/master/.github/images/swarmui.jpg\");\n    public override string OutputFolderName => \"Output\";\n    public override IEnumerable<SharedFolderMethod> AvailableSharedFolderMethods =>\n        [SharedFolderMethod.Symlink, SharedFolderMethod.Configuration, SharedFolderMethod.None];\n    public override SharedFolderMethod RecommendedSharedFolderMethod => SharedFolderMethod.Configuration;\n    public override bool OfferInOneClickInstaller => false;\n    public override bool UsesVenv => false;\n\n    public override List<ExtraPackageCommand> GetExtraCommands() =>\n        [\n            new()\n            {\n                CommandName = \"Rebuild .NET Project\",\n                Command = async installedPackage =>\n                {\n                    if (installedPackage == null || string.IsNullOrEmpty(installedPackage.FullPath))\n                    {\n                        throw new InvalidOperationException(\"Package not found or not installed correctly\");\n                    }\n\n                    var srcFolder = Path.Combine(installedPackage.FullPath, \"src\");\n                    var csprojName = \"StableSwarmUI.csproj\";\n                    if (File.Exists(Path.Combine(srcFolder, \"SwarmUI.csproj\")))\n                    {\n                        csprojName = \"SwarmUI.csproj\";\n                    }\n\n                    await RebuildDotnetProject(installedPackage.FullPath, csprojName, null)\n                        .ConfigureAwait(false);\n                },\n            },\n        ];\n\n    public override List<LaunchOptionDefinition> LaunchOptions =>\n        [\n            new LaunchOptionDefinition","sourceCodeStart":53,"sourceCodeEnd":89,"githubUrl":"https://github.com/LykosAI/StabilityMatrix/blob/af93d6ef57c01cd890d7e0ad0a9ea8c9fcda3002/StabilityMatrix.Core/Models/Packages/StableSwarm.cs#L53-L89","documentation":"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.","triggerScenarios":"Running the rebuild extra command against a null package reference or a package whose FullPath is unset (failed/removed install, stale record).","commonSituations":"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.","solutions":["Reinstall StableSwarm so its FullPath is correctly recorded, then rerun the rebuild command.","Verify the SwarmUI folder (with src/) exists at FullPath; move it back or reinstall if missing.","Delete the stale package entry and reinstall fresh.","Ensure the dotnet prerequisite is installed before rebuilding."],"exampleFix":null,"handlingStrategy":"type-guard","validationCode":"if (installedPackage is not { FullPath: { Length: > 0 } } || !Directory.Exists(installedPackage.FullPath))\n{\n    // reinstall SwarmUI before attempting the rebuild\n}","typeGuard":"bool CanRebuild(InstalledPackage? p) => p is { FullPath: { Length: > 0 } } && Directory.Exists(p.FullPath);","tryCatchPattern":"try { await rebuildCommand(installedPackage); }\ncatch (InvalidOperationException ex) when (ex.Message == \"Package not found or not installed correctly\")\n{ PromptReinstallSwarm(); }","preventionTips":["Verify the src folder exists under FullPath before rebuilding","Ensure the dotnet SDK prerequisite is installed","Reinstall after failed installs or folder relocations"],"tags":["package-validation","null-check","extra-command","dotnet"],"backgroundTag":"entity-not-found","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"}