{"record":{"id":"4d3836ad3c96c776","repo":"hashicorp/vagrant","slug":"the-name-of-your-virtual-machine-couldn-t-be-set-b-4d3836","errorCode":null,"errorMessage":"The name of your virtual machine couldn't be set because VirtualBox\nis reporting another VM with that name already exists. Most of the\ntime, this is because of an error with VirtualBox not cleaning up\nproperly. To fix this, verify that no VMs with that name do exist\n(by opening the VirtualBox GUI). If they don't, then look at the\nfolder in the error message from VirtualBox below and remove it\nif there isn't any information you need in there.\n\nVirtualBox error:\n\n%{stderr}","messagePattern":"The name of your virtual machine couldn't be set because VirtualBox\nis reporting another VM with that name already exists\\. Most of the\ntime, this is because of an error with VirtualBox not cleaning up\nproperly\\. To fix this, verify that no VMs with that name do exist\n\\(by opening the VirtualBox GUI\\)\\. If they don't, then look at the\nfolder in the error message from VirtualBox below and remove it\nif there isn't any information you need in there\\.\n\nVirtualBox error:\n\n%(.+?)","errorType":"exception","errorClass":"Vagrant::Errors.VirtualBoxNameExists","httpStatus":null,"severity":"error","filePath":"plugins/providers/virtualbox/driver/version_5_0.rb","lineNumber":782,"sourceCode":"        def remove_dhcp_server(network_name)\n          execute(\"dhcpserver\", \"remove\", \"--netname\", network_name, retryable: true)\n        end\n\n        def set_mac_address(mac)\n          mac = \"auto\" if !mac\n          execute(\"modifyvm\", @uuid, \"--macaddress1\", mac, retryable: true)\n        end\n\n        def set_name(name)\n          retryable(on: Vagrant::Errors::VBoxManageError, tries: 3, sleep: 1) do\n            begin\n              execute(\"modifyvm\", @uuid, \"--name\", name)\n            rescue Vagrant::Errors::VBoxManageError => e\n              raise if !e.extra_data[:stderr].include?(\"VERR_ALREADY_EXISTS\")\n\n              # We got VERR_ALREADY_EXISTS. This means that we're renaming to\n              # a VM name that already exists. Raise a custom error.\n              raise Vagrant::Errors::VirtualBoxNameExists,\n                    stderr: e.extra_data[:stderr]\n            end\n          end\n        end\n\n        def share_folders(folders)\n          is_solaris = begin\n                         \"SunOS\" == read_guest_property(\"/VirtualBox/GuestInfo/OS/Product\")\n                       rescue\n                         false\n                       end\n          folders.each do |folder|\n            # NOTE: Guest additions on Solaris guests do not properly handle\n            # UNC style paths so prevent conversion (See GH-7264)\n            if is_solaris\n              hostpath = folder[:hostpath]\n            else\n              hostpath = Vagrant::Util::Platform.windows_path(folder[:hostpath])","sourceCodeStart":764,"sourceCodeEnd":800,"githubUrl":"https://github.com/hashicorp/vagrant/blob/35f3160f4ad6edc3a9f3aa9570adfc1a4d73aaa5/plugins/providers/virtualbox/driver/version_5_0.rb#L764-L800","documentation":"After import, Vagrant renames the VM with `VBoxManage modifyvm <uuid> --name <name>`. If VBoxManage fails and its stderr contains VERR_ALREADY_EXISTS, the driver re-raises it as VirtualBoxNameExists. It means VirtualBox already has a VM (or a leftover on-disk machine folder) registered under that name, typically residue from an unclean destroy.","triggerScenarios":"set_name(name) inside a retryable block catches Vagrant::Errors::VBoxManageError whose extra_data[:stderr] includes 'VERR_ALREADY_EXISTS' — triggered when a VM with the target name is still registered, or the machine folder `<VirtualBox VMs>/<name>/` still exists from a previous run.","commonSituations":"A previous `vagrant destroy` failed halfway (VBoxManage locked, host crashed); duplicate machines from parallel `vagrant up` runs; a stale machine directory left in the VirtualBox VMs folder; manually imported/copied VMs sharing the name.","solutions":["Open the VirtualBox GUI and remove any VM with that name (check File > Tools > Virtual Media Manager too)","If no VM is registered, delete the leftover machine folder named in the VBoxManage stderr shown in the error","Run `vagrant global-status --prune` and destroy stale entries pointing at the same box","Retry `vagrant up` once the name collision is cleared"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"existing = `VBoxManage list vms`.scan(/^\"(.+?)\"/).flatten\nraise 'name collision' if existing.include?(target_vm_name)","typeGuard":"def vm_name_free?(name)\n  !`VBoxManage list vms`.scan(/^\"(.+?)\"/).flatten.include?(name)\nend","tryCatchPattern":null,"preventionTips":["After a failed `vagrant destroy`, verify with `VBoxManage list vms` that the VM is really gone","Periodically prune stale machines: `vagrant global-status --prune`","Avoid reusing fixed VM names when importing boxes manually"],"tags":["virtualbox","modifyvm","vm-name","verr-already-exists","cleanup"],"backgroundTag":"vm-name-already-exists","analyzedSha":"35f3160f4ad6edc3a9f3aa9570adfc1a4d73aaa5","analyzedAt":"2026-08-21T13:34:32.514Z","schemaVersion":2},"datasetVersion":"2026-08-21T18:17:14.833Z"}