{"record":{"id":"ad66a1717c440a8b","repo":"hashicorp/vagrant","slug":"the-box-you-re-using-with-the-hyper-v-provider","errorCode":null,"errorMessage":"The box you're using with the Hyper-V provider ('%{name}')\nis invalid. A Hyper-V box should contain both a\n\"Virtual Machines\" and a \"Virtual Hard Disks\" folder that are\ncreated as part of exporting a Hyper-V machine.\n\nWithin these directories, Vagrant expects to find the\nvirtual machine configuration as well as the root hard disk.\n\nThe box you're attempting to use is missing one or both of\nthese directories or does not contain the files expected. Verify\nthat you added the correct box. If this problem persists,\nplease contact the creator of the box for assistance.","messagePattern":"The box you're using with the Hyper-V provider \\('%\\{name\\}'\\)\nis invalid\\. A Hyper-V box should contain both a\n\"Virtual Machines\" and a \"Virtual Hard Disks\" folder that are\ncreated as part of exporting a Hyper-V machine\\.\n\nWithin these directories, Vagrant expects to find the\nvirtual machine configuration as well as the root hard disk\\.\n\nThe box you're attempting to use is missing one or both of\nthese directories or does not contain the files expected\\. Verify\nthat you added the correct box\\. If this problem persists,\nplease contact the creator of the box for assistance\\.","errorType":"exception","errorClass":"VagrantPlugins::HyperV::Errors::BoxInvalid","httpStatus":null,"severity":"error","filePath":"plugins/providers/hyperv/action/import.rb","lineNumber":25,"sourceCode":"module VagrantPlugins\n  module HyperV\n    module Action\n      class Import\n\n        VALID_HD_EXTENSIONS = [\".vhd\".freeze, \".vhdx\".freeze].freeze\n\n        def initialize(app, env)\n          @app = app\n          @logger = Log4r::Logger.new(\"vagrant::hyperv::import\")\n        end\n\n        def call(env)\n          vm_dir = env[:machine].box.directory.join(\"Virtual Machines\")\n          hd_dir = env[:machine].box.directory.join(\"Virtual Hard Disks\")\n\n          if !vm_dir.directory? || !hd_dir.directory?\n            @logger.error(\"Required virtual machine directory not found!\")\n            raise Errors::BoxInvalid, name: env[:machine].name\n          end\n\n          valid_config_ext = [\".xml\"]\n          if env[:machine].provider.driver.has_vmcx_support?\n            valid_config_ext << \".vmcx\"\n          end\n\n          config_path = nil\n          vm_dir.each_child do |file|\n            if valid_config_ext.include?(file.extname.downcase)\n              config_path = file\n              break\n            end\n          end\n\n          if !config_path\n            @logger.error(\"Failed to locate box configuration path\")\n            raise Errors::BoxInvalid, name: env[:machine].name","sourceCodeStart":7,"sourceCodeEnd":43,"githubUrl":"https://github.com/hashicorp/vagrant/blob/35f3160f4ad6edc3a9f3aa9570adfc1a4d73aaa5/plugins/providers/hyperv/action/import.rb#L7-L43","documentation":"The Hyper-V Import action expects the unpacked box directory to contain the two folders a Hyper-V export produces: 'Virtual Machines' and 'Virtual Hard Disks'. If either is missing, BoxInvalid is raised before any .xml/.vmcx config lookup happens - the artifact simply is not a valid Hyper-V box.","triggerScenarios":"`vagrant up --provider=hyperv` with a box built without a Hyper-V export layout: hand-assembled tarballs, boxes repackaged from other providers, or corrupted/partial extraction into the box directory.","commonSituations":"Manually crafted boxes; repackaging a VirtualBox box for Hyper-V by renaming; truncated downloads or disk-full extraction during `vagrant box add`.","solutions":["Inspect the artifact: `tar -tf box.box` must list 'Virtual Machines/' and 'Virtual Hard Disks/'","Rebuild properly: export from a working Hyper-V VM, or `vagrant package` on a Hyper-V machine, then `vagrant box add` the result","Remove the broken copy (`vagrant box remove <name>`) before re-adding the fixed artifact","Report broken published boxes to their maintainer"],"exampleFix":"# before: hand-made box\ntar -cf my.box metadata.json init.tar.gz   # -> BoxInvalid on import\n\n# after: package from a real Hyper-V VM\nvagrant halt && vagrant package --output my.box\nvagrant box add my-box my.box","handlingStrategy":"validation","validationCode":"tar -tf box.box | grep -q 'Virtual Machines/' \\\n  && tar -tf box.box | grep -q 'Virtual Hard Disks/' \\\n  || echo 'not a valid Hyper-V box'\nvagrant box add my-box box.box","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Verify box artifacts with tar -tf before adding them","Only build Hyper-V boxes by exporting from real Hyper-V VMs or `vagrant package` on hyperv","Check extraction success (disk space, download integrity) after every `vagrant box add`"],"tags":["vagrant","hyperv","box","packaging","import"],"backgroundTag":"invalid-box-format","analyzedSha":"35f3160f4ad6edc3a9f3aa9570adfc1a4d73aaa5","analyzedAt":"2026-08-21T13:34:32.514Z","schemaVersion":2},"datasetVersion":"2026-08-21T18:17:14.833Z"}