mann
mann

Reputation: 184

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.

Upvotes: 0

Views: 2103

Answers (3)

deanavenger
deanavenger

Reputation: 650

I was facing a similar issue with the latest vagrant and VirtualBox versions on macOS Ventura. In my case, the issue was solved by doing the following:

  1. Run these commands:

    sudo su
    csrutil clear
    
  2. Then uninstall VirtualBox using the official uninstaller after that reboot the system.

  3. After the reboot install VirtualBox again using:

    brew install --cask virtualbox
    
  4. Add this line to your Vagrantfile:

    virtualbox__intnet: true
    
  5. And finally:

    vagrant up
    

Upvotes: 1

Giacomo1968
Giacomo1968

Reputation: 26056

The solution is to update Vagrant to version 2.3.3.

No need to do anything else. It was a recognized and acknowledged issue and is now fixed in Vagrant 2.3.3.

The second I updated Vagrant to version 2.3.3 on my macOS 13 (Ventura) machine I was able to use my existing Vagrant script to start up without any hacks, kludges or kernel extension magic. It now works 100% as expected.

The official changelog for Vagrant 2.3.3 clearly states this; bold emphasis is mine:

2.3.3 (November 15, 2022)

IMPROVEMENTS:

  • core: Bump net-ssh dependency to 7.0 and remove patches [GH-12979]
  • synced_folders/rsync: Include ssh extra_args value [GH-12973]

BUG FIXES:

  • command/serve: Force root level namespace for Google constant [GH-12989]
  • guest/solaris: Fix insecure key authorized keys removal [GH-12740]
  • provider/virtualbox: Fix :private_network support for VirtualBox 7 on macOS [GH-12983]
  • provider/virtualbox: Prevent localization of command output [GH-12994]
  • provisioner/ansible: Update setup packages in debian capability [GH-12832]

Upvotes: 1

mann
mann

Reputation: 184

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

Upvotes: 1

Related Questions