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

You requested to remove the box '%{name}' version '%{version

Error message

You requested to remove the box '%{name}' version '%{version}'
with provider '%{provider}'. The box '%{name}' exists but not
with the provider specified. Please double-check and try again.

The providers for this are: %{providers}

What it means

Errors::BoxRemoveProviderNotFound is raised when an explicit --provider was given for removal but the resolved version of the box does not include that provider. The error lists the providers that ARE installed for that version.

Source

Thrown at lib/vagrant/action/builtin/box_remove.rb:77

            # Only a single version remains
            box_version = box_info.keys.first

            # Further filtering only matters if not removing all providers
            if !box_remove_all_providers
              # If no provider was given, check if there are more
              # than a single provider for the version
              if !box_provider && box_info.values.first.size > 1
                raise Errors::BoxRemoveMultiProvider,
                  name: box_name,
                  version: box_version,
                  providers: box_info.values.first.keys.map(&:to_s).sort.join(", ")
              end

              # If a provider was given, check the version has it
              if box_provider
                if !box_info.values.first.key?(box_provider)
                  raise Errors::BoxRemoveProviderNotFound,
                    name: box_name,
                    version: box_version,
                    provider: box_provider.to_s,
                    providers: box_info.values.first.keys.map(&:to_s).sort.join(", ")
                else
                  box_info.values.first.delete_if { |k, _| k.to_s != box_provider.to_s }
                end
              end

              # Only a single provider remains
              box_provider = box_info.values.first.keys.first

              # Further filtering only matters if not removing all architectures
              if !box_remove_all_architectures
                # If no architecture was given, check if there are more
                # than a single architecture for the provider in version
                if !box_architecture && box_info.values.first.values.first.size > 1
                  raise Errors::BoxRemoveMultiArchitecture,

View on GitHub (pinned to 35f3160f4a)

Solutions

  1. Copy the provider string from the error's 'providers for this are' list.
  2. Run 'vagrant box list' to see the exact provider labels Vagrant uses.
  3. Drop --provider and use --all-providers when the specific provider no longer matters.

Example fix

# before
vagrant box remove ubuntu/jammy64 --provider vmware   # label is vmware_workstation

# after
vagrant box remove ubuntu/jammy64 --provider vmware_workstation
Defensive patterns

Strategy: validation

Validate before calling

providers = env.box_collection.all
  .select { |n, v, *, | n == box_name && v == box_version }
  .map { |*, p, | p }
exit 0 unless providers.include?(requested_provider)

Type guard

def provider_installed?(collection, name, version, provider)
  collection.all.any? { |n, v, p, *, | n == name && v == version && p.to_s == provider.to_s }
end

Try / catch

begin
  env.cli("box", "remove", name, "--provider", prov)
rescue Vagrant::Errors::BoxRemoveProviderNotFound => e
  # e.extra_data[:providers] lists what is actually installed
  warn "try one of: #{e.extra_data[:providers]}"
end

Prevention

When it happens

Trigger: box_provider is truthy and !box_info.values.first.key?(box_provider) after version filtering; the raise carries name, version, the requested provider, and the installed providers joined with ', '.

Common situations: Misspelled provider name (vmware vs vmware_workstation); assuming a box was added for hyperv when only the virtualbox variant exists; stale cleanup scripts referencing a provider that was already removed.

Related errors


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