{"record":{"id":"46a81344e8543447","repo":"chocolatey/choco","slug":"the-0-source-does-not-support-uninstalling-pac","errorCode":null,"errorMessage":"The '{0}' source does not support uninstalling packages","messagePattern":"The '(.+?)' source does not support uninstalling packages","errorType":"exception","errorClass":"NotSupportedException","httpStatus":null,"severity":"error","filePath":"src/chocolatey/infrastructure.app/services/ChocolateyPackageService.cs","lineNumber":1267,"sourceCode":"                var environmentBefore = GetInitialEnvironment(config);\r\n\r\n                ConcurrentDictionary<string, PackageResult> results;\r\n\r\n                if (config.SourceType.IsEqualTo(SourceTypes.Normal))\r\n                {\r\n                    var action = new Action<PackageResult, ChocolateyConfiguration>(HandlePackageUninstall);\r\n                    var beforeUninstallAction = new Action<PackageResult, ChocolateyConfiguration>(BeforeModifyAction);\r\n\r\n                    results = _nugetService.Uninstall(config, action, beforeUninstallAction);\r\n                }\r\n                else\r\n                {\r\n                    results = PerformSourceRunnerFunction<IUninstallSourceRunner, ConcurrentDictionary<string, PackageResult>>(config, runner => runner.Uninstall(config, null));\r\n                }\r\n\r\n                if (results is null)\r\n                {\r\n                    throw new NotSupportedException(\"The '{0}' source does not support uninstalling packages\".FormatWith(config.SourceType));\r\n                }\r\n\r\n                foreach (var result in results)\r\n                {\r\n                    packageUninstalls.GetOrAdd(result.Key, result.Value);\r\n                }\r\n\r\n                // not handled in the uninstall handler\r\n                IEnumerable<GenericRegistryValue> environmentChanges;\r\n                IEnumerable<GenericRegistryValue> environmentRemovals;\r\n                LogEnvironmentChanges(config, environmentBefore, out environmentChanges, out environmentRemovals);\r\n            }\r\n            finally\r\n            {\r\n                var actionSummaryResult = ReportActionSummary(packageUninstalls, \"uninstalled\");\r\n                if (actionSummaryResult.Failures != 0 && Environment.ExitCode == 0)\r\n                {\r\n                    Environment.ExitCode = 1;\r","sourceCodeStart":1249,"sourceCodeEnd":1285,"githubUrl":"https://github.com/chocolatey/choco/blob/0d5abdd10cc177a141e69547cad6935b419b6c17/src/chocolatey/infrastructure.app/services/ChocolateyPackageService.cs#L1249-L1285","documentation":"Thrown as a NotSupportedException when an uninstall operation against a non-normal source type returns null results. PerformSourceRunnerFunction<IUninstallSourceRunner> is called for alternative sources; if no runner implementing IUninstallSourceRunner is registered for the given SourceType, it returns default (null) and this exception fires.","triggerScenarios":"Calling Uninstall with config.SourceType set to a non-normal value when no alternative source runner implementing IUninstallSourceRunner is registered. The null-check on results after the runner function call triggers the throw.","commonSituations":"Running 'choco uninstall pkg --source-type python' where the Python source runner does not implement IUninstallSourceRunner. Alternative source runners commonly support install but not uninstall.","solutions":["Verify the alternative source runner implements IUninstallSourceRunner for your source type.","For normal packages, do not set an alternative source type — uninstall uses the local package metadata store.","For custom runners, implement IUninstallSourceRunner and register the runner in the DI container.","If the source type does not support uninstall, remove the package through its native tool instead."],"exampleFix":"// before: runner lacks uninstall interface\npublic class MyRunner : IAlternativeSourceRunner, IInstallSourceRunner { }\n\n// after: add uninstall support\npublic class MyRunner : IAlternativeSourceRunner, IInstallSourceRunner, IUninstallSourceRunner\n{\n    public ConcurrentDictionary<string, PackageResult> Uninstall(\n        ChocolateyConfiguration config,\n        Action<PackageResult, ChocolateyConfiguration> continueAction,\n        Action<PackageResult, ChocolateyConfiguration> beforeUninstallAction)\n    {\n        return new ConcurrentDictionary<string, PackageResult>();\n    }\n}","handlingStrategy":"validation","validationCode":"// Verify a runner implementing IUninstallSourceRunner exists for the source type\nif (!config.SourceType.IsEqualTo(SourceTypes.Normal))\n{\n    var runners = _containerResolver.ResolveAll<IUninstallSourceRunner>();\n    if (!runners.Any(r => r.SourceType.IsEqualTo(config.SourceType)))\n    {\n        throw new InvalidOperationException($\"No uninstall runner registered for source type '{config.SourceType}'.\");\n    }\n}","typeGuard":"public static bool SourceTypeSupportsUninstall(string sourceType, IEnumerable<IAlternativeSourceRunner> registeredRunners)\n{\n    if (sourceType.IsEqualTo(SourceTypes.Normal)) return true;\n    return registeredRunners.OfType<IUninstallSourceRunner>().Any(r => r.SourceType.IsEqualTo(sourceType));\n}","tryCatchPattern":"try\n{\n    _packageService.Uninstall(config);\n}\ncatch (NotSupportedException ex) when (ex.Message.Contains(\"does not support uninstalling\"))\n{\n    logger.Error($\"Source type '{config.SourceType}' does not support uninstall. Use native tool or 'normal' source type.\");\n}","preventionTips":["Check whether the alternative source runner implements IUninstallSourceRunner.","For normal packages, leave SourceType as 'normal' — uninstall works against local metadata.","If the source does not support uninstall, remove the package through its native tool."],"tags":["source-runner","alternative-source","uninstall","notsupported","chocolatey"],"backgroundTag":null,"analyzedSha":"0d5abdd10cc177a141e69547cad6935b419b6c17","analyzedAt":"2026-08-13T18:33:03.301Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}