{"record":{"id":"42a08f26cfade18e","repo":"chocolatey/choco","slug":"a-value-was-passed-to-the-v-option-but-this-o","errorCode":null,"errorMessage":"\nA value was passed to the `-v` option, but this option does not support an\n explicit value.\n\nDid you mean to use `--version='{value}'` instead?\n","messagePattern":"\nA value was passed to the `-v` option, but this option does not support an\n explicit value\\.\n\nDid you mean to use `--version='(.+?)'` instead\\?\n","errorType":"validation","errorClass":"ApplicationException","httpStatus":null,"severity":"error","filePath":"src/chocolatey/infrastructure.app/configuration/ConfigurationOptions.cs","lineNumber":86,"sourceCode":"\r\n            // add help only once.\r\n            // OptionSet.Count only happens the first time\r\n            // we set the options, not when we add additional options.\r\n            if (OptionSet.Count == 0)\r\n            {\r\n                // Before we do any parsing, let us check if the\r\n                // user has passed -v=value, -v:value, -v value or /v value.\r\n                // If the user has passed this information, we will assume\r\n                // that they intended to pass a version to the command, but\r\n                // -v is a short name for --verbose, and as such we need to\r\n                // throw an exception to prevent further processing.\r\n                var joinedArguments = string.Join(\" \", args);\r\n\r\n                var match = Regex.Match(joinedArguments, @\"(^|\\s)[-/]v([=:]['\"\"]?(?<value>[^\\s'\"\"]+)| ['\"\"]?(?<value>[^\\s-'\"\"]+))\", RegexOptions.Compiled | RegexOptions.CultureInvariant);\r\n\r\n                if (match.Success)\r\n                {\r\n                    throw new ApplicationException($@\"\r\nA value was passed to the `-v` option, but this option does not support an\r\n explicit value.\r\n\r\nDid you mean to use `--version='{match.Groups[\"value\"].Value}'` instead?\r\n\");\r\n                }\r\n\r\n                OptionSet\r\n                    .Add(\"?|help|h\",\r\n                        \"Prints out the help menu.\",\r\n                        option => configuration.HelpRequested = option != null)\r\n                    .Add(\"online\",\r\n                        \"Online - Open help for specified command in default browser application. This option only works when used in combination with the -?/--help/-h option.  Available in 2.0.0+\",\r\n                        option => configuration.ShowOnlineHelp = option != null);\r\n            }\r\n\r\n            if (setOptions != null)\r\n            {\r","sourceCodeStart":68,"sourceCodeEnd":104,"githubUrl":"https://github.com/chocolatey/choco/blob/0d5abdd10cc177a141e69547cad6935b419b6c17/src/chocolatey/infrastructure.app/configuration/ConfigurationOptions.cs#L68-L104","documentation":"Thrown by ConfigurationOptions during argument parsing before any option processing begins. A regex detects patterns like '-v=value', '-v:value', '-v value', or '/v value' where -v is the short alias for --verbose (a boolean flag that takes no value). The error proactively suggests using --version='<value>' since the user almost certainly intended to specify a package version rather than set verbosity.","triggerScenarios":"Running any choco command with '-v 1.2.3', '/v=1.2.3', '-v:1.2.3', or '--verbose=true'. The regex pattern matches a value attached to or immediately following the -v short flag. This fires on every command because the check runs globally in SetOptions before command-specific parsing.","commonSituations":"User confuses -v (verbose) with --version. User follows documentation from another package manager where -v means version (e.g. npm, pip). User tries to set verbose to a boolean value. Shell scripts pass version strings via -v out of habit from other tools.","solutions":["Use --version='<value>' to specify a package version: 'choco install pkg --version=1.2.3'","Use -v or --verbose alone (no value) to enable verbose output: 'choco install pkg -v'","If setting verbosity explicitly, use --verbose without any =value suffix"],"exampleFix":"// before\nchoco install mypackage -v 1.2.3\n\n// after\nchoco install mypackage --version=1.2.3\n// or for verbose output only:\nchoco install mypackage -v","handlingStrategy":"validation","validationCode":"// Pre-validate that -v is not used with a value\nvar joinedArgs = string.Join(\" \", args);\n// Detect -v=value, -v:value, -v value, /v value patterns\nvar badVPattern = @\"(^|\\s)[-/]v([=:][^\\s]+| [^\\s-]+)\";\nif (Regex.IsMatch(joinedArgs, badVPattern))\n{\n    Console.Error.WriteLine(\"-v does not take a value. Use --version=<value> instead.\");\n    Environment.Exit(1);\n}","typeGuard":null,"tryCatchPattern":"try\n{\n    ConfigurationOptions.SetOptions(configuration, setOptions, args);\n}\ncatch (ApplicationException ex) when (ex.Message.Contains(\"-v\"))\n{\n    logger.Error(\"Invalid -v usage. Use --version='<value>' for version, -v for verbose.\");\n    Environment.Exit(1);\n}","preventionTips":["Use --verbose (no value) for verbosity, not -v=<value>","Use --version='<value>' to specify a package version","Remember that -v is the short alias for --verbose, not --version","Audit scripts for -v followed by a space and a value, which is the most common trigger"],"tags":["argument-parsing","command-args","verbose","version","regex"],"backgroundTag":null,"analyzedSha":"0d5abdd10cc177a141e69547cad6935b419b6c17","analyzedAt":"2026-08-13T18:33:03.301Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}