{"record":{"id":"e97a1f067542fd27","repo":"chocolatey/choco","slug":"a-single-config-command-must-be-listed-please-see","errorCode":null,"errorMessage":"A single config command must be listed. Please see the help menu for those commands.","messagePattern":"A single config command must be listed\\. Please see the help menu for those commands\\.","errorType":"exception","errorClass":"ApplicationException","httpStatus":null,"severity":"error","filePath":"src/chocolatey/infrastructure.app/commands/ChocolateyConfigCommand.cs","lineNumber":80,"sourceCode":"            Enum.TryParse(unparsedCommand, true, out command);\r\n            if (command == ConfigCommandType.Unknown)\r\n            {\r\n                if (!string.IsNullOrWhiteSpace(unparsedCommand))\r\n                {\r\n                    this.Log().Warn(\"Unknown command {0}. Setting to list.\".FormatWith(unparsedCommand));\r\n                }\r\n\r\n                command = ConfigCommandType.List;\r\n            }\r\n\r\n            configuration.ConfigCommand.Command = command;\r\n\r\n            if ((configuration.ConfigCommand.Command == ConfigCommandType.List\r\n                 || !string.IsNullOrWhiteSpace(configuration.ConfigCommand.Name)\r\n                )\r\n                && unparsedArguments.Count > 1)\r\n            {\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","sourceCodeStart":62,"sourceCodeEnd":98,"githubUrl":"https://github.com/chocolatey/choco/blob/0d5abdd10cc177a141e69547cad6935b419b6c17/src/chocolatey/infrastructure.app/commands/ChocolateyConfigCommand.cs#L62-L98","documentation":"The config command allows a single positional subcommand/argument. ParseAdditionalArguments throws when unparsedArguments.Count > 1 while the command is List or a name was already resolved, because multiple leftover positional tokens are ambiguous. It points the user to the help menu for valid single config commands (list/get/set/unset).","triggerScenarios":"Running 'choco config get extra', 'choco config set name value extra', or any config invocation leaving more than one unparsed positional token.","commonSituations":"Treating config like install (multiple names); quoting/parsing errors leaving stray tokens; positional value supplied alongside a name in list mode.","solutions":["Pass a single config subcommand and use --name/--value (or at most two positional tokens: name, value).","Run 'choco config -?' to see the supported subcommands.","Quote compound values and verify the count of leftover positionals."],"exampleFix":"# before\nchoco config set cacheLocation C:\\cache extra\n\n# after\nchoco config set --name cacheLocation --value C:\\cache","handlingStrategy":"validation","validationCode":"// Config takes at most one subcommand (+ up to two positional name/value).\nvar positional = tokens.Where(t => !t.StartsWith(\"-\")).ToList();\nif (positional.Count > 3)\n{\n    throw new ArgumentException(\"config: too many positional arguments\");\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Prefer --name/--value flags over positional tokens to avoid count errors.","Run 'choco config -?' to learn the supported subcommands."],"tags":["config","arguments","cli","validation"],"backgroundTag":null,"analyzedSha":"0d5abdd10cc177a141e69547cad6935b419b6c17","analyzedAt":"2026-08-13T18:33:03.301Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}