hashicorp/vagrant · error · Vagrant::Errors::CLIInvalidUsage

This command was not invoked properly. The help for this com

Error message

This command was not invoked properly. The help for this command is available below. %{help}

What it means

`vagrant cloud version delete` requires exactly two positional arguments: the `org/box-name` identifier and the version to delete. `argv.size != 2` raises CLIInvalidUsage for any other count; the -f/--force flag (which skips the y/N confirmation) is an option and does not count toward the two.

Source

Thrown at plugins/commands/cloud/version/delete.rb:32

            options = {}

            opts = OptionParser.new do |o|
              o.banner = "Usage: vagrant cloud version delete [options] organization/box-name version"
              o.separator ""
              o.separator "Deletes a version entry on Vagrant Cloud"
              o.separator ""
              o.separator "Options:"
              o.separator ""
              o.on("-f", "--[no-]force", "Force deletion without confirmation") do |f|
                options[:force] = f
              end
            end

            # Parse the options
            argv = parse_options(opts)
            return if !argv
            if argv.size != 2
              raise Vagrant::Errors::CLIInvalidUsage,
                help: opts.help.chomp
            end

            org, box_name = argv.first.split('/', 2)
            version = argv[1]

            if !options[:force]
              @env.ui.warn(I18n.t("cloud_command.version.delete_warn", version: version, box: argv.first))
              cont = @env.ui.ask(I18n.t("cloud_command.continue"))
              return 1 if cont.strip.downcase != "y"
            end

            @client = client_login(@env)

            delete_version(org, box_name, version, @client.token, options.slice)
          end

          # Delete the requested box version

View on GitHub (pinned to 35f3160f4a)

Solutions

  1. Use the exact form: `vagrant cloud version delete org/box-name version`
  2. Add -f to skip the prompt in automation: `vagrant cloud version delete -f myorg/mybox 1.0.0`
  3. Validate the version exists first with `vagrant cloud version list` style inspection or `vagrant cloud box show`

Example fix

# before
vagrant cloud version delete myorg/mybox
# after
vagrant cloud version delete -f myorg/mybox 1.0.0
Defensive patterns

Strategy: validation

Validate before calling

# bash: exactly two arguments, first slash-separated, second non-empty
if [ "$#" -ne 2 ] || ! [[ "$1" == */* ]] || [ -z "$2" ]; then
  echo "usage: vagrant cloud version delete [-f] org/box-name version" >&2
  exit 64
fi
exec vagrant cloud version delete "$@"

Try / catch

begin
  env.cli(%w[cloud version delete], org_box, version)
rescue Vagrant::Errors::CLIInvalidUsage => e
  $stderr.puts e.message.lines.first
  exit 64
end

Prevention

When it happens

Trigger: `vagrant cloud version delete myorg/mybox` (version missing); three or more arguments from splitting or extra junk; passing the confirmation answer as a positional.

Common situations: Scripts building the command from variables where the version is sometimes empty; unquoted identifiers or versions containing spaces; expecting the confirmation reply to be an argument.

Related errors


AI-assisted analysis of hashicorp/vagrant@35f3160f4a (2026-08-21). Data as JSON: /api/errors/410ece1afd264714. Report an issue: GitHub.