chocolatey/choco · error · NotSupportedException

The '{0}' source does not support upgrading packages

Error message

The '{0}' source does not support upgrading packages

What it means

Thrown as a NotSupportedException when an upgrade operation against a non-normal source type returns null results. PerformSourceRunnerFunction<IUpgradeSourceRunner> is called for alternative sources; if no runner implementing IUpgradeSourceRunner is registered, it returns default (null) and this exception fires.

Source

Thrown at src/chocolatey/infrastructure.app/services/ChocolateyPackageService.cs:1170

                GetInitialEnvironment(config, allowLogging: true);

                ConcurrentDictionary<string, PackageResult> results;

                if (config.SourceType.IsEqualTo(SourceTypes.Normal))
                {
                    var action = new Action<PackageResult, ChocolateyConfiguration>((packageResult, configuration) => HandlePackageResult(packageResult, configuration, CommandNameType.Upgrade));
                    var beforeUpgradeAction = new Action<PackageResult, ChocolateyConfiguration>((packageResult, configuration) => BeforeModifyAction(packageResult, configuration));

                    results = _nugetService.Upgrade(config, action, beforeUpgradeAction);
                }
                else
                {
                    results = PerformSourceRunnerFunction<IUpgradeSourceRunner, ConcurrentDictionary<string, PackageResult>>(config, runner => runner.Upgrade(config, null));
                }

                if (results is null)
                {
                    throw new NotSupportedException("The '{0}' source does not support upgrading packages".FormatWith(config.SourceType));
                }

                foreach (var result in results)
                {
                    packageUpgrades.GetOrAdd(result.Key, result.Value);
                }
            }
            finally
            {
                var actionSummaryResult = ReportActionSummary(packageUpgrades, "upgraded");
                if (actionSummaryResult.Failures != 0 && Environment.ExitCode == 0)
                {
                    Environment.ExitCode = 1;
                }

                if (config.Features.UseEnhancedExitCodes && (actionSummaryResult.Successes + actionSummaryResult.Failures == 0) && Environment.ExitCode == 0)
                {
                    Environment.ExitCode = 2;

View on GitHub (pinned to 0d5abdd10c)

Solutions

  1. Check whether the alternative source runner for your source type implements IUpgradeSourceRunner — some only support install.
  2. For normal feed upgrades, ensure config.SourceType is 'normal' (or omitted).
  3. For custom runners, add IUpgradeSourceRunner to the runner class and implement the Upgrade method.
  4. If the source only supports install, uninstall and reinstall instead of upgrading.

Example fix

// before: runner supports install but not upgrade
public class MyRunner : IAlternativeSourceRunner, IInstallSourceRunner { }

// after: add upgrade support
public class MyRunner : IAlternativeSourceRunner, IInstallSourceRunner, IUpgradeSourceRunner
{
    public ConcurrentDictionary<string, PackageResult> Upgrade(
        ChocolateyConfiguration config,
        Action<PackageResult, ChocolateyConfiguration> continueAction,
        Action<PackageResult, ChocolateyConfiguration> beforeUpgradeAction)
    {
        return new ConcurrentDictionary<string, PackageResult>();
    }
}
Defensive patterns

Strategy: validation

Validate before calling

// Verify a runner implementing IUpgradeSourceRunner exists for the source type
if (!config.SourceType.IsEqualTo(SourceTypes.Normal))
{
    var runners = _containerResolver.ResolveAll<IUpgradeSourceRunner>();
    if (!runners.Any(r => r.SourceType.IsEqualTo(config.SourceType)))
    {
        throw new InvalidOperationException($"No upgrade runner registered for source type '{config.SourceType}'. Not all alternative sources support upgrade.");
    }
}

Type guard

public static bool SourceTypeSupportsUpgrade(string sourceType, IEnumerable<IAlternativeSourceRunner> registeredRunners)
{
    if (sourceType.IsEqualTo(SourceTypes.Normal)) return true;
    return registeredRunners.OfType<IUpgradeSourceRunner>().Any(r => r.SourceType.IsEqualTo(sourceType));
}

Try / catch

try
{
    _packageService.Upgrade(config);
}
catch (NotSupportedException ex) when (ex.Message.Contains("does not support upgrading"))
{
    logger.Error($"Source type '{config.SourceType}' does not support upgrade. Try uninstall + install instead.");
}

Prevention

When it happens

Trigger: Calling Upgrade with config.SourceType set to a non-normal value when no alternative source runner implementing IUpgradeSourceRunner is registered for that source type. The null-check on results after the runner function completes triggers the throw.

Common situations: Running 'choco upgrade --source-type python' where the Python source runner does not implement IUpgradeSourceRunner. Many alternative source runners only support install, not upgrade. Also occurs with typo'd or unregistered source types.

Related errors


AI-assisted analysis of chocolatey/choco@0d5abdd10c (2026-08-13). Data as JSON: /api/errors/7610810606f60cf2. Report an issue: GitHub.