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 box delete` requires exactly one positional argument: the `org/box-name` identifier of the box to delete. CLIInvalidUsage is raised when argv is empty or has more than one entry; the message includes the command help describing the -f/--force flag that skips the deletion confirmation prompt.

Source

Thrown at plugins/commands/cloud/box/delete.rb:33

            opts = OptionParser.new do |o|
              o.banner = "Usage: vagrant cloud box delete [options] organization/box-name"
              o.separator ""
              o.separator "Deletes box entry on Vagrant Cloud"
              o.separator ""
              o.separator "Options:"
              o.separator ""

              o.on("-f", "--[no-]force", "Do not prompt for deletion confirmation") do |f|
                options[:force] = f
              end
            end

            # Parse the options
            argv = parse_options(opts)
            return if !argv
            if argv.empty? || argv.length > 1
              raise Vagrant::Errors::CLIInvalidUsage,
                help: opts.help.chomp
            end

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

            @client = client_login(@env)

            org, box_name = argv.first.split('/', 2)
            delete_box(org, box_name, @client.token)
          end

          # Delete the requested box
          #
          # @param [String] org Organization name of box

View on GitHub (pinned to 35f3160f4a)

Solutions

  1. Pass exactly one identifier: `vagrant cloud box delete myorg/mybox`
  2. Add -f to skip the y/N prompt in scripts: `vagrant cloud box delete -f myorg/mybox`
  3. Verify the identifier exists first with `vagrant cloud box show myorg/mybox`

Example fix

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

Strategy: validation

Validate before calling

# bash: exactly one argument, and it must contain a slash
if [ "$#" -ne 1 ] || ! [[ "$1" == */* ]]; then
  echo "usage: vagrant cloud box delete [-f] org/box-name" >&2
  exit 64
fi
exec vagrant cloud box delete "$@"

Try / catch

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

Prevention

When it happens

Trigger: Running `vagrant cloud box delete` with no argument; passing two or more positionals (e.g. `vagrant cloud box delete myorg mybox`); extra trailing arguments forwarded by a wrapper script.

Common situations: Splitting the org and box name into two arguments; scripting a delete loop where the identifier variable is sometimes empty; expecting a confirmation answer to be a positional argument.

Related errors


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