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 provider delete` requires three or four positional arguments: `organization/box-name`, provider name, version, and optionally an architecture. Fewer than three or more than four entries raises CLIInvalidUsage; note the confirmation prompt (skippable with -f) only runs after the argument guard passes.

Source

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

            options = {}

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

            # Parse the options
            argv = parse_options(opts)
            return if !argv
            if argv.count < 3 || argv.count > 4
              raise Vagrant::Errors::CLIInvalidUsage,
                help: opts.help.chomp
            end

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

            @client = client_login(@env)
            account = VagrantCloud::Account.new(
              custom_server: api_server_url,
              access_token: @client.token
            )

            if architecture.nil?
              architecture = select_provider_architecture(account, org, box_name, version, provider_name)
            end

View on GitHub (pinned to 35f3160f4a)

Solutions

  1. Use the exact form: `vagrant cloud provider delete org/box-name provider version [architecture]`
  2. Add -f to skip the y/N confirmation in automation
  3. Check `vagrant cloud provider delete -h` for the banner

Example fix

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

Strategy: validation

Validate before calling

# bash: enforce 3-or-4 arguments, first one slash-separated
if [ "$#" -lt 3 ] || [ "$#" -gt 4 ] || ! [[ "$1" == */* ]]; then
  echo "usage: vagrant cloud provider delete [-f] org/box-name provider version [architecture]" >&2
  exit 64
fi
exec vagrant cloud provider delete "$@"

Try / catch

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

Prevention

When it happens

Trigger: `vagrant cloud provider delete myorg/mybox` (provider and version missing); only three of the needed pieces plus an extra trailing argument; a version passed twice.

Common situations: Copying the two-argument style from `vagrant cloud box delete`; forgetting that architecture is a positional here; scripts that always pass four args hitting the >4 guard when an identifier contains a space and splits.

Related errors


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