I have a Vagrantfile
that configures a host-only network. Running vagrant up
fails with the error
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: Permission denied
VBoxManage: error: Details: code NS_ERROR_FAILURE (0x80004005), component HostNetworkInterfaceWrap, interface IHostNetworkInterface
VBoxManage: error: Context: "RTEXITCODE handleCreate(HandlerArg*)" at line 94 of file VBoxManageHostonly.cpp
Manually removing the adapter with e.g. VBoxManage hostonlyif remove vboxnet0
seems to work, but ip a
indicates that it is still present:
[me@nixos:~/code/vagrant-test]$ VBoxManage hostonlyif remove vboxnet0
0%...10%...20%...30%...40%...50%...60%...70%...80%...90%...100%
[me@nixos:~/code/vagrant-test]$ ip a
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
valid_lft forever preferred_lft forever
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
<snip>
4: vboxnet0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc pfifo_fast state DOWN group default qlen 1000
link/ether 0a:00:27:00:00:00 brd ff:ff:ff:ff:ff:ff
inet 192.168.56.1/24 scope global vboxnet0
valid_lft forever preferred_lft forever
Removing the adapters from the VirtualBox GUI works correctly.
configuration.nix
: virtualisation.virtualbox.host.enable = true;
nixpkgs.config.virtualbox.enableExtensionPack = true; # I'm not sure this is relevant
Install VirtualBox (with guest additions, although I don't think that's relevant) and vagrant with nix-env -i virtualbox
and nix-env -i vagrant
Create a new Vagrantfile
:
vagrant init nastevens/alpine-3.5-x86_64
Vagrantfile
: config.vm.network "private_network", nic_type: "virtio", ip: "192.168.33.10", auto_config: true
vagrant up
Turns out that this was caused by having both virtualisation.virtualbox.host.enable = true;
as well as nix-env -i virtualbox
Can you explain a little more, please?
I had Virtualbox installed in two different ways, which was causing my issue. The solution was to uninstall the user package and put virtualisation.virtualbox.host.enable = true;
in my configuration.nix
.
Most helpful comment
Turns out that this was caused by having both
virtualisation.virtualbox.host.enable = true;
as well asnix-env -i virtualbox