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
Thrown by ChocolateyTemplateCommand.Validate when the subcommand is not 'list' and no --name was provided. Non-list template operations (e.g. 'info') require a --name to identify which template to get information about. Without a name the operation has no target.
Source
Thrown at src/chocolatey/infrastructure.app/commands/ChocolateyTemplateCommand.cs:82
if (command == TemplateCommandType.Unknown)
{
if (!string.IsNullOrWhiteSpace(unparsedCommand))
{
this.Log().Warn("Unknown command {0}. Setting to list.".FormatWith(unparsedCommand));
}
command = TemplateCommandType.List;
}
configuration.TemplateCommand.Command = command;
}
public virtual void Validate(ChocolateyConfiguration configuration)
{
if (configuration.TemplateCommand.Command != TemplateCommandType.List && string.IsNullOrWhiteSpace(configuration.TemplateCommand.Name))
{
throw new ApplicationException("When specifying the subcommand '{0}', you must also specify --name.".FormatWith(configuration.TemplateCommand.Command.ToStringSafe().ToLower()));
}
}
public virtual void HelpMessage(ChocolateyConfiguration configuration)
{
"chocolatey".Log().Info(ChocolateyLoggers.Important, "Template Command");
"chocolatey".Log().Info(@"
List information installed templates.
Both manually installed templates and templates installed via
.template packages are displayed.");
"chocolatey".Log().Info(ChocolateyLoggers.Important, "Usage");
"chocolatey".Log().Info(@"
choco template [list]|info [<options/switches>]");
"chocolatey".Log().Info(ChocolateyLoggers.Important, "Examples");
"chocolatey".Log().Info(@"
View on GitHub (pinned to 0d5abdd10c)
Solutions
- Add the --name flag: 'choco template info --name=<template-id>'.
- Run 'choco template list' first to see available template names.
- If you want to list all templates, use 'choco template list'.
Example fix
// before choco template info // after choco template info --name="mytemplate"
Defensive patterns
Strategy: validation
Validate before calling
// For non-list template ops, ensure --name
if (templateSubcommand != "list" && string.IsNullOrWhiteSpace(templateName))
{
Console.Error.WriteLine($"choco template {templateSubcommand} requires --name=<template>.");
} Prevention
- Always include --name with 'choco template info'.
- Run 'choco template list' to see available template names.
When it happens
Trigger: Running 'choco template info' without --name=<template-name>. The condition: TemplateCommand.Command != List AND TemplateCommand.Name is empty.
Common situations: User runs 'choco template info' expecting a full listing (that is 'list'). User forgets to specify which template. Script omits --name due to variable issues.
Related errors
- When specifying the subcommand '{0}', you must also specify
- A Rule Name (-n|--name) is required when getting information
- When specifying the subcommand '{0}', you must also specify
- Package name is required. Please pass at least one package n
- No rule with the name {0} could be found.
AI-assisted analysis of chocolatey/choco@0d5abdd10c (2026-08-13).
Data as JSON: /api/errors/f1dd3abb21dde414.
Report an issue: GitHub.