Search code examples
vagrantvirtualboxmacos-monterey

Error executing VBoxManage on VirtualBox when running “vagrant up” in terminal in macOS Monterey 12.0.1


I am running macOS Monterey 12.0.1 with Vagrant 2.2.19 and VirtualBox 6.1.30. When I attempt to start up Vagrant via the mac terminal using vagrant up this error message is returned:

Bringing machine 'homestead' up with 'virtualbox' provider...
==> homestead: Checking if box 'laravel/homestead' version '11.5.0' is up to date...
==> homestead: Clearing any previously set network interfaces...
There was an error while executing `VBoxManage`, a CLI used by Vagrant
for controlling VirtualBox. The command and stderr is shown below.

Command: ["hostonlyif", "create"]

Stderr: 0%...
Progress state: NS_ERROR_FAILURE
VBoxManage: error: Failed to create the host-only adapter
VBoxManage: error: VBoxNetAdpCtl: Error while adding new interface: failed to open /dev/vboxnetctl: No such file or directory
VBoxManage: error: Details: code NS_ERROR_FAILURE (0x80004005), component HostNetworkInterfaceWrap, interface IHostNetworkInterface
VBoxManage: error: Context: "RTEXITCODE handleCreate(HandlerArg *)" at line 95 of file VBoxManageHostonly.cpp

I have tried uninstalling and reinstalling both VirtualBox and Vagrant along with reboots of macOS but I'm still getting the same above message.

In my search for an answer I keep coming across a suggestion to add this to my Vagrantfile but I'm unsure where it needs to be inserted since it does not currently have it in my file and no one ever states where in the file to insert it:

config.vm.provider "virtualbox" do |v|  v.gui = true end

Also, within the codebase for Vagrant, I found this snippet indicating it might be a kernel driver needing to be installed or properly installed. But I'm not finding any references on driver installation.

if r.stderr =~ /failed to open \/dev\/vboxnetctl/i
  # This catches an error message that only shows when kernel
  # drivers aren't properly installed.
  @logger.error("Error message about unable to open vboxnetctl")
  raise Vagrant::Errors::VirtualBoxKernelModuleNotLoaded
end

Any guidance on how I might make changes to my configuration to Vagrant or VirtualBox to get vagrant up and passed the error messages would be appreciated.


Solution

  • Someone directed me to this post: https://laracasts.com/discuss/channels/general-discussion/homestead-macos-monterey-boot-issue-headless-error-virtualbox?page=1&replyId=744904

    Since I am using a newer version of virtualbox 6.1.30 than listed in this post and 6.1.30 fixes virtualbox installing I decided to move on to retrying the kernal extension commands listed (after confirming that the files referenced already existed which they do).

    The commands are:

    sudo kextload /Library/Application\ Support/VirtualBox/VBoxDrv.kext -r /Library/Extensions
    sudo kextload /Library/Application\ Support/VirtualBox/VBoxNetAdp.kext -r /Library/Extensions
    sudo kextload /Library/Application\ Support/VirtualBox/VBoxNetFlt.kext -r /Library/Extensions
    sudo kextload /Library/Application\ Support/VirtualBox/VBoxUSB.kext -r /Library/Extensions
    

    The second command responded that I needed to reboot. So I ignored, went ahead and ran the rest of the commands, THEN rebooted the computer.

    Then in the Homestead project directory I ran vagrant up again. This time it worked successfully and is still running headless - a bit like me. :)

    Additional notes (In case I need to come back for my own answers):

    • It will take a while to bring vagrant up since it is actually building the virtualbox environment to be used.
    • running this for a laravel project, and received The Mix manifest does not exist after running php artisan serve and navigating to localhost. To resolve I ran php artisan vendor:publish --provider="Laravel\Horizon\HorizonServiceProvider"
    • (If I recall correctly) during this step I needed to go to Mac System Preferences > Security and Privacy settings and click allow.
    • followed by npm ci && npm run dev
    • lastly run npm run watch