{"record":{"id":"dee68d18b33feb87","repo":"chocolatey/choco","slug":"when-specifying-the-subcommand-0-you-must-als-dee68d","errorCode":null,"errorMessage":"When specifying the subcommand '{0}', you must also specify --name.","messagePattern":"When specifying the subcommand '(.+?)', you must also specify --name\\.","errorType":"validation","errorClass":"ApplicationException","httpStatus":null,"severity":"error","filePath":"src/chocolatey/infrastructure.app/commands/ChocolateyPinCommand.cs","lineNumber":96,"sourceCode":"                {\r\n                    this.Log().Warn(\"Unknown command {0}. Setting to list.\".FormatWith(unparsedCommand));\r\n                }\r\n\r\n                command = PinCommandType.List;\r\n            }\r\n\r\n            configuration.PinCommand.Command = command;\r\n            configuration.Sources = ApplicationParameters.PackagesLocation;\r\n            configuration.ListCommand.LocalOnly = true;\r\n            configuration.AllVersions = true;\r\n            configuration.Prerelease = true;\r\n        }\r\n\r\n        public virtual void Validate(ChocolateyConfiguration configuration)\r\n        {\r\n            if (configuration.PinCommand.Command != PinCommandType.List && string.IsNullOrWhiteSpace(configuration.PinCommand.Name))\r\n            {\r\n                throw new ApplicationException(\"When specifying the subcommand '{0}', you must also specify --name.\".FormatWith(configuration.PinCommand.Command.ToStringSafe().ToLower()));\r\n            }\r\n        }\r\n\r\n        public virtual void HelpMessage(ChocolateyConfiguration configuration)\r\n        {\r\n            this.Log().Info(ChocolateyLoggers.Important, \"Pin Command\");\r\n            this.Log().Info(@\"\r\nPin a package to suppress upgrades.\r\n\r\nThis is especially helpful when running `choco upgrade` for all\r\n packages, as it will automatically skip those packages. Another\r\n alternative is `choco upgrade --except=\"\"pkg1,pk2\"\"`.\r\n\");\r\n\r\n            \"chocolatey\".Log().Info(ChocolateyLoggers.Important, \"Usage\");\r\n            \"chocolatey\".Log().Info(@\"\r\n    choco pin [list]|add|remove [<options/switches>]\r\n\");\r","sourceCodeStart":78,"sourceCodeEnd":114,"githubUrl":"https://github.com/chocolatey/choco/blob/0d5abdd10cc177a141e69547cad6935b419b6c17/src/chocolatey/infrastructure.app/commands/ChocolateyPinCommand.cs#L78-L114","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Add the --name flag: 'choco pin add --name=<package-id>'.","If you want to list pins (which does not require --name), use 'choco pin list'.","Double-check package id spelling against installed packages with 'choco list --local-only'."],"exampleFix":"// before\nchoco pin add\n// after\nchoco pin add --name=\"googlechrome\"","handlingStrategy":"validation","validationCode":"// For add/remove, always provide --name\nif (pinSubcommand != \"list\" && string.IsNullOrWhiteSpace(packageName))\n{\n    Console.Error.WriteLine($\"choco pin {pinSubcommand} requires --name=<package>.\");\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always include --name when using 'choco pin add' or 'choco pin remove'.","Use 'choco pin list' when no specific package is needed."],"tags":["chocolatey","pin-command","missing-argument","validation"],"backgroundTag":null,"analyzedSha":"0d5abdd10cc177a141e69547cad6935b419b6c17","analyzedAt":"2026-08-13T18:33:03.301Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}