chocolatey/choco · error · Exception

The implementation of '{0}' does not support listing.

Error message

The implementation of '{0}' does not support listing.

What it means

Thrown by GenericRunner.Count when the resolved command does not implement IListCommand (the non-generic interface). The Count method requires the command to support listing operations because counting is conceptually a listing capability. If the command exists but cannot be cast to IListCommand, it has no count functionality and the error is thrown.

Source

Thrown at src/chocolatey/infrastructure.app/runners/GenericRunner.cs:310

                {
                    task.Shutdown();
                }

                RemoveNuGetCache(container, config);
            }
        }

        public int Count(ChocolateyConfiguration config, Container container, bool isConsole, Action<ICommand> parseArgs)
        {
            FailOnMissingOrInvalidLicenseIfFeatureSet(config);
            HttpsSecurity.Reset();

            var command = FindCommand(config, container, isConsole, parseArgs) as IListCommand;
            if (command == null)
            {
                if (!string.IsNullOrWhiteSpace(config.CommandName))
                {
                    throw new Exception("The implementation of '{0}' does not support listing.".FormatWith(config.CommandName));
                }
                return 0;
            }
            else
            {
                this.Log().Debug("_ {0}:{1} - Normal Count Mode _".FormatWith(ApplicationParameters.Name, command.GetType().Name));
                return command.Count(config);
            }
        }

        public void WarnIfAdminAndNeedsElevation(ChocolateyConfiguration config)
        {
            if (config.HelpRequested)
            {
                return;
            }

            // skip when commands will set or for background mode

View on GitHub (pinned to 0d5abdd10c)

Solutions

  1. Use a command that supports listing/counting (e.g. 'choco search' or 'choco list')
  2. Verify the command name is correct for the intended count operation
  3. Ensure the source type supports listing if using alternative sources
  4. Check that the command's runner implements IListCommand

Example fix

// before
choco push --count
// throws: The implementation of 'push' does not support listing.

// after
choco search mypackage --count
// or
choco list --count
Defensive patterns

Strategy: type-guard

Validate before calling

// Check command capability before calling Count
var command = FindCommand(config, container, isConsole, parseArgs);
if (command is IListCommand listCommand)
{
    return listCommand.Count(config);
}
else
{
    logger.Warn($"Command '{config.CommandName}' does not support IListCommand for counting.");
    return 0;
}

Type guard

public static bool SupportsCount(ICommand command)
{
    return command is IListCommand;
}

Try / catch

try
{
    var count = runner.Count(config, container, isConsole, parseArgs);
}
catch (Exception ex) when (ex.Message.Contains("does not support listing"))
{
    logger.Error($"Command '{config.CommandName}' does not support counting. Use 'choco list --count'.");
    return 0;
}

Prevention

When it happens

Trigger: Running 'choco <command> --count' or an internal API call to GenericRunner.Count where the command is resolved but doesn't implement IListCommand. The command supports installation or other operations but not listing/counting. An alternative source runner type is set but doesn't have list capability.

Common situations: User or script invokes a count operation on a command that doesn't support it (e.g. 'choco push --count'). Internal code path incorrectly routes a count request to a non-listing command. Alternative source type is configured but the runner doesn't support search/count.

Related errors


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