chocolatey/choco · error · ApplicationException

A single license command must be listed. Please see the help

Error message

A single license command must be listed. Please see the help menu for those commands

What it means

The license command accepts at most one positional subcommand. ParseAdditionalArguments throws when unparsedArguments.Count > 1, because multiple leftover positional tokens are ambiguous. It directs the user to the help menu for the single license subcommands (info).

Source

Thrown at src/chocolatey/infrastructure.app/commands/ChocolateyLicenseCommand.cs:45

using System.Text.RegularExpressions;

namespace chocolatey.infrastructure.app.commands
{
    [CommandFor("license", "display Chocolatey license information", Version = "2.5.0")]
    public class ChocolateyLicenseCommand : ChocolateyCommandBase, ICommand
    {
        private static readonly Regex _licenseCountRegex = new Regex(@"\[.*?(?<licensedMachineCount>\d+).*?\]");

        public void ConfigureArgumentParser(OptionSet optionSet, ChocolateyConfiguration configuration)
        {
            // We don't currently expect to have any arguments
        }

        public void ParseAdditionalArguments(IList<string> unparsedArguments, ChocolateyConfiguration configuration)
        {
            if (unparsedArguments.Count > 1)
            {
                throw new ApplicationException("A single license command must be listed. Please see the help menu for those commands");
            }

            var command = LicenseCommandType.Unknown;
            var unparsedCommand = unparsedArguments.DefaultIfEmpty(string.Empty).FirstOrDefault();
            Enum.TryParse(unparsedCommand, true, out command);

            if (command == LicenseCommandType.Unknown)
            {
                if (!string.IsNullOrWhiteSpace(unparsedCommand))
                {
                    this.Log().Warn("Unknown command {0}. Setting to info.".FormatWith(unparsedCommand));
                }

                command = LicenseCommandType.Info;
            }

            configuration.LicenseCommand.Command = command;
        }

View on GitHub (pinned to 0d5abdd10c)

Solutions

  1. Pass a single license subcommand: 'choco license info'.
  2. Run 'choco license -?' to confirm supported subcommands.
  3. Check that quoted strings don't leave stray positional tokens.

Example fix

# before
choco license info extra

# after
choco license info
Defensive patterns

Strategy: validation

Validate before calling

// License command: single positional argument max.
var positional = tokens.Where(t => !t.StartsWith("-")).ToList();
if (positional.Count > 1)
{
    throw new ArgumentException("license: too many positional arguments");
}

Prevention

When it happens

Trigger: Running 'choco license info extra' or any license invocation leaving more than one unparsed positional token.

Common situations: Passing multiple license arguments; misparsing options as positionals; scripting that concatenates tokens.

Related errors


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