chocolatey/choco · error · ApplicationException

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

Error message

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

What it means

Thrown by ChocolateySourceCommand.ParseAdditionalArguments when more than one unparsed positional argument is supplied to 'choco source'. The source command accepts exactly one subcommand verb (list, add, remove, disable, enable); two or more positional tokens are ambiguous and rejected.

Source

Thrown at src/chocolatey/infrastructure.app/commands/ChocolateySourceCommand.cs:87

                 .Add("bypassproxy|bypass-proxy",
                     "Bypass Proxy - Should this source explicitly bypass any explicitly or system configured proxies? Defaults to false.",
                     option => configuration.SourceCommand.BypassProxy = option != null)
                 .Add("allowselfservice|allow-self-service",
                     "Allow Self-Service - Should this source be allowed to be used with self-service? Requires business edition with feature 'useBackgroundServiceWithSelfServiceSourcesOnly' turned on. Defaults to false.",
                     option => configuration.SourceCommand.AllowSelfService = option != null)
                 .Add("adminonly|admin-only",
                     "Visible to Administrators Only - Should this source be visible to non-administrators? Requires business edition. Defaults to false.",
                     option => configuration.SourceCommand.VisibleToAdminsOnly = option != null)
                ;
        }

        public virtual void ParseAdditionalArguments(IList<string> unparsedArguments, ChocolateyConfiguration configuration)
        {
            configuration.Input = string.Join(" ", unparsedArguments);

            if (unparsedArguments.Count > 1)
            {
                throw new ApplicationException("A single sources command must be listed. Please see the help menu for those commands");
            }

            var command = SourceCommandType.Unknown;
            var unparsedCommand = unparsedArguments.DefaultIfEmpty(string.Empty).FirstOrDefault();
            Enum.TryParse(unparsedCommand, true, out command);
            if (command == SourceCommandType.Unknown)
            {
                if (!string.IsNullOrWhiteSpace(unparsedCommand))
                {
                    this.Log().Warn("Unknown command {0}. Setting to list.".FormatWith(unparsedCommand));
                }

                command = SourceCommandType.List;
            }

            configuration.SourceCommand.Command = command;
        }

View on GitHub (pinned to 0d5abdd10c)

Solutions

  1. Pass only a single source subcommand per invocation: 'choco source add', 'choco source list', etc.
  2. For multiple source operations, issue separate 'choco source' calls.
  3. Run 'choco source --help' to review accepted subcommands.

Example fix

// before
choco source add list --name=myfeed
// after
choco source add --name=myfeed --source="https://feed/"
choco source list
Defensive patterns

Strategy: validation

Validate before calling

// Ensure only one positional subcommand
if (positionalArgs.Count(arg => !arg.StartsWith("-")) > 1)
{
    Console.Error.WriteLine("Pass a single source subcommand (list, add, remove, disable, enable).");
}

Prevention

When it happens

Trigger: Running 'choco source add list', 'choco source add remove', or any invocation with 2+ positional arguments. The check is unparsedArguments.Count > 1.

Common situations: User chains multiple source operations in one command. A script concatenates arguments incorrectly. User misunderstands syntax, thinking subcommands can be combined.

Related errors


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