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 ChocolateySourceCommand.Validate when the subcommand is not 'list' and no --name was provided. All non-list source operations (add, remove, disable, enable) require a --name to identify which source to act upon. Without a name the operation has no target.
Source
Thrown at src/chocolatey/infrastructure.app/commands/ChocolateySourceCommand.cs:110
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;
}
public virtual void Validate(ChocolateyConfiguration configuration)
{
if (configuration.SourceCommand.Command != SourceCommandType.List && string.IsNullOrWhiteSpace(configuration.SourceCommand.Name))
{
throw new ApplicationException("When specifying the subcommand '{0}', you must also specify --name.".FormatWith(configuration.SourceCommand.Command.ToStringSafe().ToLower()));
}
if (configuration.SourceCommand.Command == SourceCommandType.Add && string.IsNullOrWhiteSpace(configuration.Sources))
{
throw new ApplicationException("When specifying the subcommand 'add', you must also specify --source.");
}
if (!string.IsNullOrWhiteSpace(configuration.SourceCommand.Username) && string.IsNullOrWhiteSpace(configuration.SourceCommand.Password))
{
this.Log().Debug(ChocolateyLoggers.LogFileOnly, "Username '{0}' provided. Asking for password.".FormatWith(configuration.SourceCommand.Username));
System.Console.Write("User name '{0}' provided. Password: ".FormatWith(configuration.SourceCommand.Username));
configuration.SourceCommand.Password = InteractivePrompt.GetPassword(configuration.PromptForConfirmation);
}
}
public virtual void HelpMessage(ChocolateyConfiguration configuration)
{
this.Log().Info(ChocolateyLoggers.Important, "Source Command");
View on GitHub (pinned to 0d5abdd10c)
Solutions
- Add the --name flag with the source name: 'choco source disable --name=myfeed'.
- Run 'choco source list' first to see configured source names.
- For add operations, also remember --source (the URL) is required.
Example fix
// before choco source disable // after choco source disable --name="myfeed"
Defensive patterns
Strategy: validation
Validate before calling
// For non-list source ops, ensure --name
if (sourceSubcommand != "list" && string.IsNullOrWhiteSpace(sourceName))
{
Console.Error.WriteLine($"choco source {sourceSubcommand} requires --name=<source>.");
} Prevention
- Always include --name for add/remove/disable/enable source operations.
- Run 'choco source list' to see configured source names.
When it happens
Trigger: Running 'choco source add', 'choco source remove', 'choco source disable', or 'choco source enable' without --name=<source-name>. The condition: SourceCommand.Command != List AND SourceCommand.Name is empty.
Common situations: User runs 'choco source disable' without specifying which source. User expects an interactive prompt but the command requires explicit --name. Script omits --name due to a variable expansion issue.
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 'add', you must also specify
- When specifying the subcommand '{0}', you must also specify
- Package name is required. Please pass at least one package n
AI-assisted analysis of chocolatey/choco@0d5abdd10c (2026-08-13).
Data as JSON: /api/errors/d0c3dbf86e5de405.
Report an issue: GitHub.