{"record":{"id":"bb3458143aac8caa","repo":"hashicorp/vagrant","slug":"the-box-you-attempted-to-add-doesn-t-match-the-pro","errorCode":null,"errorMessage":"The box you attempted to add doesn't match the provider you specified.\n\nProvider expected: %{expected}\nProvider of box: %{actual}","messagePattern":"The box you attempted to add doesn't match the provider you specified\\.\n\nProvider expected: %(.+?)\nProvider of box: %(.+?)","errorType":"exception","errorClass":"Vagrant::Errors::BoxProviderDoesntMatch","httpStatus":null,"severity":"error","filePath":"lib/vagrant/box_collection.rb","lineNumber":151,"sourceCode":"          end\n\n          # We re-wrap ourselves in the safety net in case we upgraded.\n          # If we didn't upgrade, then this is still safe because the\n          # helper will only delete the directory if it exists\n          with_temp_dir(temp_dir) do |final_temp_dir|\n            # Get an instance of the box we just added before it is finalized\n            # in the system so we can inspect and use its metadata.\n            box = Box.new(name, nil, version, final_temp_dir)\n\n            # Get the provider, since we'll need that to at the least add it\n            # to the system or check that it matches what is given to us.\n            box_provider = box.metadata[\"provider\"]\n\n            if providers\n              found = providers.find { |p| p.to_sym == box_provider.to_sym }\n              if !found\n                @logger.error(\"Added box provider doesnt match expected: #{log_provider}\")\n                raise Errors::BoxProviderDoesntMatch,\n                  expected: log_provider, actual: box_provider\n              end\n            else\n              # Verify the box doesn't already exist\n              check_box_exists.call([box_provider], architecture)\n            end\n\n            # We weren't given a provider, so store this one.\n            provider = box_provider.to_sym\n\n            # Create the directory for this box, not including the provider\n            root_box_dir = @directory.join(dir_name(name))\n            box_dir = root_box_dir.join(version)\n            box_dir.mkpath\n            @logger.debug(\"Box directory: #{box_dir}\")\n\n            # This is the final directory we'll move it to\n            if architecture","sourceCodeStart":133,"sourceCodeEnd":169,"githubUrl":"https://github.com/hashicorp/vagrant/blob/35f3160f4ad6edc3a9f3aa9570adfc1a4d73aaa5/lib/vagrant/box_collection.rb#L133-L169","documentation":"BoxProviderDoesntMatch is raised in BoxCollection#add (lib/vagrant/box_collection.rb:151) after unpacking: the freshly extracted box's metadata.json declares provider X, but the caller requested a providers list that does not include X. Vagrant refuses to register the box under a provider it is not built for.","triggerScenarios":"'vagrant box add my.box --provider virtualbox' where the unpacked metadata.json says \"provider\": \"vmware_desktop\": providers.find { |p| p.to_sym == box_provider.to_sym } returns nil and the error is raised with expected vs actual. Also occurs when Vagrantfile's provider and the box source disagree.","commonSituations":"Downloading a VMware/Hyper-V/QEMU build while the Vagrantfile or CLI targets VirtualBox; multi-provider catalogs where the wrong artifact link was grabbed; renaming a .box does not change its true provider.","solutions":["Add with the provider the box actually declares: 'vagrant box add my.box --provider vmware_desktop'","Or download the correct artifact for your provider from the catalog and add that file","Check the box's declared provider first: 'bsdtar -xOf my.box ./metadata.json' (path may be 'metadata.json' at archive root)"],"exampleFix":"# before\nvagrant box add ./mybox.box --provider virtualbox   # box is actually vmware_desktop\n\n# after\nvagrant box add ./mybox.box --provider vmware_desktop\n# or fetch the virtualbox build from the catalog instead","handlingStrategy":"validation","validationCode":"require 'json'\nrequire 'open3'\nout, = Open3.capture2('bsdtar', '-xOf', box_path.to_s, 'metadata.json')\ndeclared = JSON.parse(out)['provider']\nraise \"box is #{declared}, not #{wanted}\" unless declared == wanted","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Fetch provider-specific artifacts from catalog URLs instead of renaming local .box files","In CI, assert the box's declared provider matches the Vagrantfile provider before 'vagrant up'"],"tags":["vagrant","box","provider","mismatch","metadata"],"backgroundTag":"artifact-platform-mismatch","analyzedSha":"35f3160f4ad6edc3a9f3aa9570adfc1a4d73aaa5","analyzedAt":"2026-08-21T13:34:32.514Z","schemaVersion":2},"datasetVersion":"2026-08-21T18:17:14.833Z"}