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

Raised by `vagrant box repackage` when the number of positional arguments is not exactly three (name, provider, version). The command indexes argv[0]/argv[1]/argv[2] directly - the provider is even to_sym'd - so the arity is strict and the banner `Usage: vagrant box repackage <name> <provider> <version>` is embedded in the error.

Source

Thrown at plugins/commands/box/command/repackage.rb:20

# SPDX-License-Identifier: BUSL-1.1

require "fileutils"
require 'optparse'
require "pathname"

module VagrantPlugins
  module CommandBox
    module Command
      class Repackage < Vagrant.plugin("2", :command)
        def execute
          opts = OptionParser.new do |o|
            o.banner = "Usage: vagrant box repackage <name> <provider> <version>"
          end

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

          box_name     = argv[0]
          box_provider = argv[1].to_sym
          box_version  = argv[2]

          # Verify the box exists that we want to repackage
          box = @env.boxes.find(box_name, box_provider, "= #{box_version}")
          if !box
            raise Vagrant::Errors::BoxNotFoundWithProviderAndVersion,
              name: box_name,
              provider: box_provider.to_s,
              version: box_version
          end

          # Repackage the box
          output_name = @env.vagrantfile.config.package.name || "package.box"
          output_path = Pathname.new(File.expand_path(output_name, FileUtils.pwd))
          box.repackage(output_path)

View on GitHub (pinned to 35f3160f4a)

Solutions

  1. Get the exact triple from `vagrant box list` (name, provider, version)
  2. Run: `vagrant box repackage <name> <provider> <version>`
  3. Use --help to confirm the argument order

Example fix

# before
vagrant box repackage ubuntu/jammy

# after
vagrant box list   # find exact version
vagrant box repackage ubuntu/jammy virtualbox 202303.0.0
Defensive patterns

Strategy: validation

Validate before calling

# bash: repackage requires exactly 3 positionals: name provider version
[ $# -eq 3 ] || { vagrant box repackage --help; exit 1; }
vagrant box repackage "$1" "$2" "$3"

Prevention

When it happens

Trigger: `vagrant box repackage mybox` (missing provider/version), `vagrant box repackage mybox virtualbox` (missing version), or four-plus positional words.

Common situations: Assuming the version is optional or defaults to latest; forgetting that repackage needs the exact installed version.

Related errors


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