{"record":{"id":"061a428fc0fce150","repo":"chocolatey/choco","slug":"when-specifying-the-subcommand-0-you-must-als-061a42","errorCode":null,"errorMessage":"When specifying the subcommand '{0}', you must also specify --value by option or position.","messagePattern":"When specifying the subcommand '(.+?)', you must also specify --value by option or position\\.","errorType":"exception","errorClass":"ApplicationException","httpStatus":null,"severity":"error","filePath":"src/chocolatey/infrastructure.app/commands/ChocolateyConfigCommand.cs","lineNumber":102,"sourceCode":"            {\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\n\");\r\n\r\n            \"chocolatey\".Log().Info(ChocolateyLoggers.Important, \"Examples\");\r\n            \"chocolatey\".Log().Info(@\"\r\n    choco config\r","sourceCodeStart":84,"sourceCodeEnd":120,"githubUrl":"https://github.com/chocolatey/choco/blob/0d5abdd10cc177a141e69547cad6935b419b6c17/src/chocolatey/infrastructure.app/commands/ChocolateyConfigCommand.cs#L84-L120","documentation":"Validate() requires a value when setting a config entry. If ConfigCommand.Command == Set and configuration.ConfigCommand.ConfigValue is blank, it throws, naming the subcommand. A set needs both a target name and the value to write.","triggerScenarios":"Running 'choco config set --name <setting>' (or 'set name') with no --value and no positional value token.","commonSituations":"Supplying the name but omitting the value; passing the value on the wrong side of the name; quoting that collapses the value to empty.","solutions":["Add --value <value> (or a positional value): 'choco config set --name cacheLocation --value C:\\cache'.","To clear a setting, use the appropriate unset/empty handling rather than omitting the value.","Verify the value is not whitespace-only."],"exampleFix":"# before\nchoco config set --name cacheLocation\n\n# after\nchoco config set --name cacheLocation --value C:\\choco\\cache","handlingStrategy":"validation","validationCode":"// 'set' requires a value.\nif (configVerb == \"set\" && string.IsNullOrWhiteSpace(value))\n{\n    throw new InvalidOperationException(\"config set requires --value\");\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always pair --name with --value for config set.","Trim and assert the value is not whitespace-only before invoking choco."],"tags":["config","validation","value","set"],"backgroundTag":null,"analyzedSha":"0d5abdd10cc177a141e69547cad6935b419b6c17","analyzedAt":"2026-08-13T18:33:03.301Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}