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

The box '%{name}' (v%{version}) with provider '%{provider}'

Error message

The box '%{name}' (v%{version}) with provider '%{provider}'
could not be found. Please double check and try again. You
can see all the boxes that are installed with `vagrant box list`.

What it means

Raised by `vagrant box repackage` after argument parsing when `@env.boxes.find(box_name, box_provider, "= #{box_version}")` returns nil - no installed box matches the exact name/provider/version triple. The lookup pins the version with an exact `= version` Gem constraint, so an approximate or differently-formatted version string fails even if the box exists at another version.

Source

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

      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)

          # Success, exit status 0
          0
        end
      end
    end
  end
end

View on GitHub (pinned to 35f3160f4a)

Solutions

  1. Run `vagrant box list` and copy the exact name, provider, and version shown
  2. Retry repackage with that exact triple
  3. If the box is missing, add it first with `vagrant box add`

Example fix

# before
vagrant box repackage ubuntu/jammy virtualbox 1.0.0
# error: box not found with provider and version

# after
vagrant box list   # shows ubuntu/jammy (virtualbox, 202303.0.0)
vagrant box repackage ubuntu/jammy virtualbox 202303.0.0
Defensive patterns

Strategy: validation

Validate before calling

# bash: confirm the exact triple exists before repackaging
vagrant box list | grep "^${BOX} " | grep -q "${PROVIDER}" | grep -q "${VERSION}" ||
  { echo "box not installed: ${BOX} ${PROVIDER} ${VERSION}"; vagrant box list; exit 1; }

Type guard

# Ruby: same lookup the command uses, as a predicate
def box_installed?(env, name, provider, version)
  !env.boxes.find(name, provider.to_sym, "= #{version}").nil?
end

Try / catch

begin
  box.repackage(output_path)
rescue Vagrant::Errors::BoxNotFoundWithProviderAndVersion => e
  warn "installed boxes: #{env.boxes.all.map(&:first).uniq.join(', ')}"
  raise
end

Prevention

When it happens

Trigger: `vagrant box repackage ubuntu/jammy virtualbox 1.0.0` when the installed version is 202303.0.0; a provider that does not match the installed one; the box simply not installed at all.

Common situations: Guessing the version instead of copying it from `vagrant box list`; using 'latest' or a partial version; case mismatch in the box slug (owner/name).

Understand the failure class

Background: 'Could not be found', 'does not exist', 'not found in database': the resource-not-found family when an ID, slug, key, or URI lookup comes back empty — this error's family across 20 libraries.

Related errors


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