{"record":{"id":"05080d0ffdec4dc0","repo":"hashicorp/vagrant","slug":"the-virtualbox-vm-was-created-with-a-user-that-doe","errorCode":null,"errorMessage":"The VirtualBox VM was created with a user that doesn't match the\ncurrent user running Vagrant. VirtualBox requires that the same user\nbe used to manage the VM that was created. Please re-run Vagrant with\nthat user. This is not a Vagrant issue.\n\nThe UID used to create the VM was: %{original_uid}\nYour UID is: %{uid}","messagePattern":"The VirtualBox VM was created with a user that doesn't match the\ncurrent user running Vagrant\\. VirtualBox requires that the same user\nbe used to manage the VM that was created\\. Please re-run Vagrant with\nthat user\\. This is not a Vagrant issue\\.\n\nThe UID used to create the VM was: %(.+?)\nYour UID is: %(.+?)","errorType":"exception","errorClass":"Vagrant::Errors.VirtualBoxUserMismatch","httpStatus":null,"severity":"error","filePath":"plugins/providers/virtualbox/provider.rb","lineNumber":97,"sourceCode":"        return {\n          host: \"127.0.0.1\",\n          port: @driver.ssh_port(@machine.config.ssh.guest_port)\n        }\n      end\n\n      # Return the state of VirtualBox virtual machine by actually\n      # querying VBoxManage.\n      #\n      # @return [Symbol]\n      def state\n        # We have to check if the UID matches to avoid issues with\n        # VirtualBox.\n        if Vagrant::Util::Platform.wsl_windows_access_bypass?(@machine.data_dir)\n          @logger.warn(\"Skipping UID check on machine by user request for WSL Windows access.\")\n        else\n          uid = @machine.uid\n          if uid && uid.to_s != Process.uid.to_s\n            raise Vagrant::Errors::VirtualBoxUserMismatch,\n              original_uid: uid.to_s,\n              uid: Process.uid.to_s\n          end\n        end\n\n        # Determine the ID of the state here.\n        state_id = nil\n        state_id = :not_created if !@driver.uuid\n        state_id = @driver.read_state if !state_id\n        state_id = :unknown if !state_id\n\n        # Translate into short/long descriptions\n        short = state_id.to_s.gsub(\"_\", \" \")\n        long  = I18n.t(\"vagrant.commands.status.#{state_id}\")\n\n        # If we're not created, then specify the special ID flag\n        if state_id == :not_created\n          state_id = Vagrant::MachineState::NOT_CREATED_ID","sourceCodeStart":79,"sourceCodeEnd":115,"githubUrl":"https://github.com/hashicorp/vagrant/blob/35f3160f4ad6edc3a9f3aa9570adfc1a4d73aaa5/plugins/providers/virtualbox/provider.rb#L79-L115","documentation":"Before querying VM state, the VirtualBox provider verifies that the UID stored in the machine's data dir (`@machine.uid`, recorded when the VM was created) matches the current Process.uid. VirtualBox user-level state cannot be managed across users, so a mismatch raises VirtualBoxUserMismatch with both UIDs. There is an explicit bypass for WSL Windows access when the user opted into it via wsl_windows_access_bypass? for the data dir.","triggerScenarios":"Calling state (almost any vagrant command touching the machine: up, status, ssh, destroy) when the .vagrant data dir was created by a different OS user — e.g. running `sudo vagrant ...`, switching accounts, or a shared project directory used by two users.","commonSituations":"Running vagrant with sudo 'to fix' permission errors; project cloned/copied from another user's home; CI running under a different service account than the interactive user who first ran `vagrant up`; WSL setups where the VM was created from Windows but vagrant runs in WSL without the bypass env var.","solutions":["Re-run vagrant as the user listed in 'The UID used to create the VM was:'","Or recreate the VM under the current user: `vagrant destroy` (as the original user) then `vagrant up` as the intended account","For WSL/Windows interop, set the wsl_windows_access_* machine config/env option so the bypass applies to that data dir","Avoid `sudo vagrant`; fix the underlying permission problem instead"],"exampleFix":"# before — created as user 1000, now running under another account\n$ sudo vagrant up   # -> VirtualBoxUserMismatch (original_uid: 1000, uid: 0)\n# after — run as the creating user, or rebuild\n$ vagrant destroy; vagrant up   # run WITHOUT sudo, as the original user","handlingStrategy":"validation","validationCode":"uid_file = File.read(File.join(project_dir, '.vagrant/machines/<name>/virtualbox/id')) rescue nil\n# simpler: check owner of the .vagrant dir\nowner_uid = File.stat(File.join(project_dir, '.vagrant')).uid\nabort 'run vagrant as the user who created the VM' if owner_uid != Process.uid","typeGuard":"def machine_owner_matches?(machine)\n  machine.uid.nil? || machine.uid.to_s == Process.uid.to_s\nend","tryCatchPattern":null,"preventionTips":["Never run `sudo vagrant`; fix permissions instead","Standardize one OS account for vagrant usage per project checkout","For WSL/Windows mixed use, configure the wsl_windows_access bypass deliberately"],"tags":["virtualbox","uid","user-mismatch","permissions","wsl"],"backgroundTag":"vm-ownership-mismatch","analyzedSha":"35f3160f4ad6edc3a9f3aa9570adfc1a4d73aaa5","analyzedAt":"2026-08-21T13:34:32.514Z","schemaVersion":2},"datasetVersion":"2026-08-21T18:17:14.833Z"}