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 by option or position. What it means
Validate() requires a setting name for any config subcommand other than List. If ConfigCommand.Command != List and configuration.ConfigCommand.Name is blank, it throws, naming the offending subcommand. get/set/unset all need to know which config key to act on.
Source
Thrown at src/chocolatey/infrastructure.app/commands/ChocolateyConfigCommand.cs:97
{
throw new ApplicationException("A single config command must be listed. Please see the help menu for those commands.");
}
if (string.IsNullOrWhiteSpace(configuration.ConfigCommand.Name) && unparsedArguments.Count >= 2)
{
configuration.ConfigCommand.Name = unparsedArguments[1];
}
if (string.IsNullOrWhiteSpace(configuration.ConfigCommand.ConfigValue) && unparsedArguments.Count >= 3)
{
configuration.ConfigCommand.ConfigValue = unparsedArguments[2];
}
}
public virtual void Validate(ChocolateyConfiguration configuration)
{
if (configuration.ConfigCommand.Command != ConfigCommandType.List && string.IsNullOrWhiteSpace(configuration.ConfigCommand.Name))
{
throw new ApplicationException("When specifying the subcommand '{0}', you must also specify --name by option or position.".FormatWith(configuration.ConfigCommand.Command.ToStringSafe().ToLower()));
}
if (configuration.ConfigCommand.Command == ConfigCommandType.Set && string.IsNullOrWhiteSpace(configuration.ConfigCommand.ConfigValue))
{
throw new ApplicationException("When specifying the subcommand '{0}', you must also specify --value by option or position.".FormatWith(configuration.ConfigCommand.Command.ToStringSafe().ToLower()));
}
}
public virtual void HelpMessage(ChocolateyConfiguration configuration)
{
this.Log().Info(ChocolateyLoggers.Important, "Config Command");
this.Log().Info(@"
Chocolatey will allow you to interact with the configuration file settings.
");
"chocolatey".Log().Info(ChocolateyLoggers.Important, "Usage");
"chocolatey".Log().Info(@"
choco config [list]|get|set|unset [<options/switches>]
View on GitHub (pinned to 0d5abdd10c)
Solutions
- Add --name <setting> (or a positional name): 'choco config get --name cacheLocation'.
- Use 'choco config list' to discover valid setting names first.
- Ensure the name token isn't being consumed as a flag.
Example fix
# before choco config set C:\cache # after choco config set --name cacheLocation --value C:\cache
Defensive patterns
Strategy: validation
Validate before calling
// Non-list config subcommands require a name.
if (configVerb != "list" && string.IsNullOrWhiteSpace(name))
{
throw new InvalidOperationException($"config {configVerb} requires --name");
} Prevention
- Use 'choco config list' to discover valid setting names.
- Always pass --name for get/set/unset in scripts.
When it happens
Trigger: Running 'choco config get', 'choco config set', or 'choco config unset' without --name and without a positional name token.
Common situations: Forgetting the setting name; passing the name as a value; assuming a bare subcommand lists/operates on all settings.
Related errors
- When specifying the subcommand '{0}', you must also specify
- A single config command must be listed. Please see the help
- When specifying the subcommand '{0}', you must also specify
- Name is required. Please pass in a name for the new package.
- Feature '{0}' is not supported.
AI-assisted analysis of chocolatey/choco@0d5abdd10c (2026-08-13).
Data as JSON: /api/errors/a851ed1617c1b259.
Report an issue: GitHub.