chocolatey/choco · error · ApplicationException

When specifying the subcommand '{0}', you must also specify

Error message

When specifying the subcommand '{0}', you must also specify --name.

What it means

Validate() requires a feature name for any feature subcommand other than List. If FeatureCommand.Command != List and configuration.FeatureCommand.Name is blank, it throws, naming the offending subcommand. enable/disable need to know which feature to toggle.

Source

Thrown at src/chocolatey/infrastructure.app/commands/ChocolateyFeatureCommand.cs:90

            if ((configuration.FeatureCommand.Command == FeatureCommandType.List
                 || !string.IsNullOrWhiteSpace(configuration.FeatureCommand.Name)
                )
                && unparsedArguments.Count > 1)
            {
                throw new ApplicationException("A single feature command must be listed. Please see the help menu for those commands.");
            }

            if (string.IsNullOrWhiteSpace(configuration.FeatureCommand.Name) && unparsedArguments.Count >= 2)
            {
                configuration.FeatureCommand.Name = unparsedArguments[1];
            }
        }

        public virtual void Validate(ChocolateyConfiguration configuration)
        {
            if (configuration.FeatureCommand.Command != FeatureCommandType.List && string.IsNullOrWhiteSpace(configuration.FeatureCommand.Name))
            {
                throw new ApplicationException("When specifying the subcommand '{0}', you must also specify --name.".FormatWith(configuration.FeatureCommand.Command.ToStringSafe().ToLower()));
            }
        }

        public virtual void HelpMessage(ChocolateyConfiguration configuration)
        {
            this.Log().Info(ChocolateyLoggers.Important, "Feature Command");
            this.Log().Info(@"
Chocolatey will allow you to interact with features.
");

            "chocolatey".Log().Info(ChocolateyLoggers.Important, "Usage");
            "chocolatey".Log().Info(@"
    choco feature [list]|disable|enable [<options/switches>]
");

            "chocolatey".Log().Info(ChocolateyLoggers.Important, "Examples");
            "chocolatey".Log().Info(@"
    choco feature

View on GitHub (pinned to 0d5abdd10c)

Solutions

  1. Add --name <feature> (or a positional name): 'choco feature disable -n checkSumFiles'.
  2. Run 'choco feature list' to discover valid feature names first.
  3. Quote names containing dashes to avoid flag interpretation.

Example fix

# before
choco feature enable

# after
choco feature enable --name useEnhancedExitCodes
Defensive patterns

Strategy: validation

Validate before calling

// Non-list feature subcommands require a name.
if (featureVerb != "list" && string.IsNullOrWhiteSpace(featureName))
{
    throw new InvalidOperationException($"feature {featureVerb} requires --name");
}

Prevention

When it happens

Trigger: Running 'choco feature enable' or 'choco feature disable' without --name and without a positional name token.

Common situations: Forgetting the feature name; assuming a bare subcommand toggles all features; the name token getting parsed as a flag.

Related errors


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