{"record":{"id":"a851ed1617c1b259","repo":"chocolatey/choco","slug":"when-specifying-the-subcommand-0-you-must-als","errorCode":null,"errorMessage":"When specifying the subcommand '{0}', you must also specify --name by option or position.","messagePattern":"When specifying the subcommand '(.+?)', you must also specify --name by option or position\\.","errorType":"exception","errorClass":"ApplicationException","httpStatus":null,"severity":"error","filePath":"src/chocolatey/infrastructure.app/commands/ChocolateyConfigCommand.cs","lineNumber":97,"sourceCode":"            {\r\n                throw new ApplicationException(\"A single config command must be listed. Please see the help menu for those commands.\");\r\n            }\r\n\r\n            if (string.IsNullOrWhiteSpace(configuration.ConfigCommand.Name) && unparsedArguments.Count >= 2)\r\n            {\r\n                configuration.ConfigCommand.Name = unparsedArguments[1];\r\n            }\r\n            if (string.IsNullOrWhiteSpace(configuration.ConfigCommand.ConfigValue) && unparsedArguments.Count >= 3)\r\n            {\r\n                configuration.ConfigCommand.ConfigValue = unparsedArguments[2];\r\n            }\r\n        }\r\n\r\n        public virtual void Validate(ChocolateyConfiguration configuration)\r\n        {\r\n            if (configuration.ConfigCommand.Command != ConfigCommandType.List && string.IsNullOrWhiteSpace(configuration.ConfigCommand.Name))\r\n            {\r\n                throw new ApplicationException(\"When specifying the subcommand '{0}', you must also specify --name by option or position.\".FormatWith(configuration.ConfigCommand.Command.ToStringSafe().ToLower()));\r\n            }\r\n\r\n            if (configuration.ConfigCommand.Command == ConfigCommandType.Set && string.IsNullOrWhiteSpace(configuration.ConfigCommand.ConfigValue))\r\n            {\r\n                throw new ApplicationException(\"When specifying the subcommand '{0}', you must also specify --value by option or position.\".FormatWith(configuration.ConfigCommand.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, \"Config Command\");\r\n            this.Log().Info(@\"\r\nChocolatey will allow you to interact with the configuration file settings.\r\n\");\r\n\r\n            \"chocolatey\".Log().Info(ChocolateyLoggers.Important, \"Usage\");\r\n            \"chocolatey\".Log().Info(@\"\r\n    choco config [list]|get|set|unset [<options/switches>]\r","sourceCodeStart":79,"sourceCodeEnd":115,"githubUrl":"https://github.com/chocolatey/choco/blob/0d5abdd10cc177a141e69547cad6935b419b6c17/src/chocolatey/infrastructure.app/commands/ChocolateyConfigCommand.cs#L79-L115","documentation":"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.","triggerScenarios":"Running 'choco config get', 'choco config set', or 'choco config unset' without --name and without a positional name token.","commonSituations":"Forgetting the setting name; passing the name as a value; assuming a bare subcommand lists/operates on all settings.","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."],"exampleFix":"# before\nchoco config set C:\\cache\n\n# after\nchoco config set --name cacheLocation --value C:\\cache","handlingStrategy":"validation","validationCode":"// Non-list config subcommands require a name.\nif (configVerb != \"list\" && string.IsNullOrWhiteSpace(name))\n{\n    throw new InvalidOperationException($\"config {configVerb} requires --name\");\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Use 'choco config list' to discover valid setting names.","Always pass --name for get/set/unset in scripts."],"tags":["config","validation","name","set"],"backgroundTag":null,"analyzedSha":"0d5abdd10cc177a141e69547cad6935b419b6c17","analyzedAt":"2026-08-13T18:33:03.301Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}