chocolatey/choco · error · NotSupportedException
The '{0}' source does not support searching for packages
Error message
The '{0}' source does not support searching for packages What it means
Thrown as a NotSupportedException when a non-normal source type (e.g. cygwin, python, ruby, windowsfeatures) fails to return search or list results. PerformSourceRunnerFunction resolves an ISearchableSourceRunner (or IListSourceRunner for LocalOnly) for the configured SourceType; if no registered runner implements that interface the function returns default (null), and the subsequent null-check fires this exception. The exact message variant depends on config.ListCommand.LocalOnly — 'listing' vs 'searching'.
Source
Thrown at src/chocolatey/infrastructure.app/services/ChocolateyPackageService.cs:281
IEnumerable<PackageResult> results;
if (config.ListCommand.LocalOnly && !config.SourceType.IsEqualTo(SourceTypes.Normal))
{
results = PerformSourceRunnerFunction<IListSourceRunner, IEnumerable<PackageResult>>(config, runner => runner.List(config));
}
else if (config.SourceType.IsEqualTo(SourceTypes.Normal))
{
results = _nugetService.List(config).OrEmpty();
}
else
{
results = PerformSourceRunnerFunction<ISearchableSourceRunner, IEnumerable<PackageResult>>(config, runner => runner.Search(config));
}
if (results is null)
{
var message = config.ListCommand.LocalOnly ? "The '{0}' source does not support listing of packages".FormatWith(config.SourceType) : "The '{0}' source does not support searching for packages".FormatWith(config.SourceType);
throw new NotSupportedException(message);
}
foreach (PackageResult package in results)
{
if (config.SourceType.IsEqualTo(SourceTypes.Normal))
{
if (!config.ListCommand.IncludeRegistryPrograms)
{
yield return package;
}
if (config.ListCommand.LocalOnly && config.ListCommand.IncludeRegistryPrograms && package.PackageMetadata != null)
{
packages.Add(package);
}
}
}
View on GitHub (pinned to 0d5abdd10c)
Solutions
- Verify the --source-type value is valid and that its corresponding runner implements ISearchableSourceRunner or IListSourceRunner.
- If using a normal NuGet/Chocolatey feed, ensure config.SourceType equals SourceTypes.Normal so the _nugetService.List path is taken instead of the runner path.
- For custom alternative source runners, implement the ISearchableSourceRunner interface (Search method) or IListSourceRunner (List method) on the runner class and register it in the container.
- If listing locally installed packages, set config.ListCommand.LocalOnly = true and ensure the runner implements IListSourceRunner.
Example fix
// before: runner missing the interface
public class MyCustomRunner : IAlternativeSourceRunner
{
// no Search or List implementation
}
// after: implement the required interface
public class MyCustomRunner : IAlternativeSourceRunner, ISearchableSourceRunner
{
public IEnumerable<PackageResult> Search(ChocolateyConfiguration config)
{
// return results, never null
return Enumerable.Empty<PackageResult>();
}
} Defensive patterns
Strategy: validation
Validate before calling
// Before calling List, verify the source type supports the operation
var supportedSourceTypes = new[] { SourceTypes.Normal, SourceTypes.Cygwin, SourceTypes.Python, SourceTypes.WindowsFeatures };
if (!supportedSourceTypes.Contains(config.SourceType, StringComparer.OrdinalIgnoreCase))
{
throw new InvalidOperationException($"Unsupported source type: {config.SourceType}");
}
if (!config.SourceType.IsEqualTo(SourceTypes.Normal))
{
var runners = _containerResolver.ResolveAll<ISearchableSourceRunner>();
if (!runners.Any(r => r.SourceType.IsEqualTo(config.SourceType)))
{
// warn user before the API call fails
throw new InvalidOperationException($"Source type '{config.SourceType}' has no runner implementing ISearchableSourceRunner.");
}
} Type guard
public static bool SourceTypeSupportsSearch(string sourceType, IEnumerable<IAlternativeSourceRunner> registeredRunners)
{
if (sourceType.IsEqualTo(SourceTypes.Normal)) return true;
return registeredRunners.OfType<ISearchableSourceRunner>().Any(r => r.SourceType.IsEqualTo(sourceType));
} Try / catch
try
{
var results = _packageService.List(config);
foreach (var pkg in results) { /* process */ }
}
catch (NotSupportedException ex) when (ex.Message.Contains("does not support"))
{
// Surface a user-friendly message about unsupported source type
logger.Error($"Source type '{config.SourceType}' cannot search. Use --source-type=normal or install the appropriate runner.");
} Prevention
- Always verify config.SourceType is set to a known SourceTypes constant before calling List/Search.
- Register custom alternative source runners in the DI container with the appropriate interfaces (ISearchableSourceRunner, IListSourceRunner).
- Test source type operations with dry-run commands before production use.
When it happens
Trigger: Calling List() on ChocolateyPackageService with config.SourceType set to an alternative source (not 'normal') when either (a) no alternative source runner implementing ISearchableSourceRunner/IListSourceRunner is registered in the DI container, or (b) the resolved runner exists but its Search/List method returns null. The LocalOnly flag selects the runner interface and the error message variant.
Common situations: A user or automation script runs 'choco search --source-type python' or 'choco list --local-only --source-type windowsfeatures' against a source type whose runner does not implement the required search/list interface. Also occurs when a custom alternative source runner is registered but missing the ISearchableSourceRunner interface implementation.
Related errors
- The '{0}' source does not support installing packages
- The '{0}' source does not support upgrading packages
- The '{0}' source does not support uninstalling packages
- No runner was found that implements source type '{0}' or, it
- The '{0}' source does not support listing of packages
AI-assisted analysis of chocolatey/choco@0d5abdd10c (2026-08-13).
Data as JSON: /api/errors/4fb4ce4aad8cc416.
Report an issue: GitHub.