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 update` raises CLIInvalidUsage in three cases: no positional argument, more than one, or exactly one argument but none of the update fields (--description, --short-description, --[no-]private) were supplied. The third branch exists because an update with nothing to change is meaningless; the command needs to know what to modify.

Source

Thrown at plugins/commands/cloud/box/update.rb:39

              o.separator "Options:"
              o.separator ""

              o.on("-d", "--description DESCRIPTION", "Full description of the box") do |d|
                options[:description] = d
              end
              o.on("-s", "--short-description DESCRIPTION", "Short description of the box") do |s|
                options[:short] = s
              end
              o.on("-p", "--[no-]private", "Makes box private") do |p|
                options[:private] = p
              end
            end

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

            @client = client_login(@env)
            org, box_name = argv.first.split('/', 2)

            update_box(org, box_name, @client.token, options.slice(:short, :description, :private))
          end

          # Update an existing box
          #
          # @param [String] org Organization name of box
          # @param [String] box_name Name of box
          # @param [String] access_token User access token
          # @param [Hash] options Options for box filtering
          # @option options [String] :short Short description of box
          # @option options [String] :description Full description of box
          # @option options [Boolean] :private Set box visibility as private

View on GitHub (pinned to 35f3160f4a)

Solutions

  1. Include at least one field: `vagrant cloud box update -s "New short description" myorg/mybox`
  2. Use exactly one positional identifier in org/box-name form
  3. Check `vagrant cloud box update -h` to see all accepted field options

Example fix

# before
vagrant cloud box update myorg/mybox
# after
vagrant cloud box update -p --short-description "Updated box" myorg/mybox
Defensive patterns

Strategy: validation

Validate before calling

# Mirror the command's own contract: exactly one positional plus at least one field flag
pos = args.reject { |a| a.start_with?("-") }
has_field = args.any? { |a| %w[-d -s -p --description --short-description --private --no-private].include?(a) }
unless pos.size == 1 && has_field
  abort "usage: vagrant cloud box update org/box-name (-d | -s | -p)"
end

Try / catch

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

Prevention

When it happens

Trigger: Running `vagrant cloud box update` with no identifier; two or more positionals; `vagrant cloud box update myorg/mybox` with zero field flags — the guard `options.slice(:description, :short, :private).length == 0` fires.

Common situations: Expecting the command to re-sync metadata with no changes; setting only flags the command ignores (e.g. --force) and no actual field; forgetting the -d/-s/-p flags in ported scripts.

Related errors


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