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 ChocolateyPinCommand.Validate when the pin subcommand is not 'list' and no --name was provided. The 'add' and 'remove' subcommands require a target package name to pin or unpin. Without a name the operation has no target and is rejected.

Source

Thrown at src/chocolatey/infrastructure.app/commands/ChocolateyPinCommand.cs:96

                {
                    this.Log().Warn("Unknown command {0}. Setting to list.".FormatWith(unparsedCommand));
                }

                command = PinCommandType.List;
            }

            configuration.PinCommand.Command = command;
            configuration.Sources = ApplicationParameters.PackagesLocation;
            configuration.ListCommand.LocalOnly = true;
            configuration.AllVersions = true;
            configuration.Prerelease = true;
        }

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

        public virtual void HelpMessage(ChocolateyConfiguration configuration)
        {
            this.Log().Info(ChocolateyLoggers.Important, "Pin Command");
            this.Log().Info(@"
Pin a package to suppress upgrades.

This is especially helpful when running `choco upgrade` for all
 packages, as it will automatically skip those packages. Another
 alternative is `choco upgrade --except=""pkg1,pk2""`.
");

            "chocolatey".Log().Info(ChocolateyLoggers.Important, "Usage");
            "chocolatey".Log().Info(@"
    choco pin [list]|add|remove [<options/switches>]
");

View on GitHub (pinned to 0d5abdd10c)

Solutions

  1. Add the --name flag: 'choco pin add --name=<package-id>'.
  2. If you want to list pins (which does not require --name), use 'choco pin list'.
  3. Double-check package id spelling against installed packages with 'choco list --local-only'.

Example fix

// before
choco pin add
// after
choco pin add --name="googlechrome"
Defensive patterns

Strategy: validation

Validate before calling

// For add/remove, always provide --name
if (pinSubcommand != "list" && string.IsNullOrWhiteSpace(packageName))
{
    Console.Error.WriteLine($"choco pin {pinSubcommand} requires --name=<package>.");
}

Prevention

When it happens

Trigger: Running 'choco pin add' or 'choco pin remove' without the --name=<package> option. The check fires when configuration.PinCommand.Command != List AND configuration.PinCommand.Name is null/empty/whitespace.

Common situations: User runs 'choco pin add' expecting to pin all packages or forgetting to specify which package. The command requires an explicit package name for add/remove operations.

Related errors


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