chocolatey/choco · error · ApplicationException

A value was passed to the `-v` option, but this option does

Error message

A value was passed to the `-v` option, but this option does not support an
 explicit value.

Did you mean to use `--version='{value}'` instead?

What it means

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.

Source

Thrown at src/chocolatey/infrastructure.app/configuration/ConfigurationOptions.cs:86

            // add help only once.
            // OptionSet.Count only happens the first time
            // we set the options, not when we add additional options.
            if (OptionSet.Count == 0)
            {
                // Before we do any parsing, let us check if the
                // user has passed -v=value, -v:value, -v value or /v value.
                // If the user has passed this information, we will assume
                // that they intended to pass a version to the command, but
                // -v is a short name for --verbose, and as such we need to
                // throw an exception to prevent further processing.
                var joinedArguments = string.Join(" ", args);

                var match = Regex.Match(joinedArguments, @"(^|\s)[-/]v([=:]['""]?(?<value>[^\s'""]+)| ['""]?(?<value>[^\s-'""]+))", RegexOptions.Compiled | RegexOptions.CultureInvariant);

                if (match.Success)
                {
                    throw new ApplicationException($@"
A value was passed to the `-v` option, but this option does not support an
 explicit value.

Did you mean to use `--version='{match.Groups["value"].Value}'` instead?
");
                }

                OptionSet
                    .Add("?|help|h",
                        "Prints out the help menu.",
                        option => configuration.HelpRequested = option != null)
                    .Add("online",
                        "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+",
                        option => configuration.ShowOnlineHelp = option != null);
            }

            if (setOptions != null)
            {

View on GitHub (pinned to 0d5abdd10c)

Solutions

  1. Use --version='<value>' to specify a package version: 'choco install pkg --version=1.2.3'
  2. Use -v or --verbose alone (no value) to enable verbose output: 'choco install pkg -v'
  3. If setting verbosity explicitly, use --verbose without any =value suffix

Example fix

// before
choco install mypackage -v 1.2.3

// after
choco install mypackage --version=1.2.3
// or for verbose output only:
choco install mypackage -v
Defensive patterns

Strategy: validation

Validate before calling

// Pre-validate that -v is not used with a value
var joinedArgs = string.Join(" ", args);
// Detect -v=value, -v:value, -v value, /v value patterns
var badVPattern = @"(^|\s)[-/]v([=:][^\s]+| [^\s-]+)";
if (Regex.IsMatch(joinedArgs, badVPattern))
{
    Console.Error.WriteLine("-v does not take a value. Use --version=<value> instead.");
    Environment.Exit(1);
}

Try / catch

try
{
    ConfigurationOptions.SetOptions(configuration, setOptions, args);
}
catch (ApplicationException ex) when (ex.Message.Contains("-v"))
{
    logger.Error("Invalid -v usage. Use --version='<value>' for version, -v for verbose.");
    Environment.Exit(1);
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of chocolatey/choco@0d5abdd10c (2026-08-13). Data as JSON: /api/errors/42a08f26cfade18e. Report an issue: GitHub.