Being too eager, as I generally am, I went straight ahead and updated to OSX Mavericks when it launched yesterday, and it broke my development environment.
So how do you go about fixing Vagrant after an OSX Mavericks update?
Updated: 30th October – issues with starting VM on computer restart
Updated: 5th November – changes to VirtualBox in version 4.3
After updating to OSX Mavericks, I was getting the following error message:
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 HostNetworkInterface, interface IHostNetworkInterface
VBoxManage: error: Context: "int handleCreate(HandlerArg*, int, int*)" at line 68 of file VBoxManageHostonly.cpp
After trying to update VirtualBox (didn’t work), refresh Vagrant (didn’t work), review permissions on the Vagrant folders (didn’t work), I stumbled across the following command, which seemed to do the trick in fixing Vagrant after the OSX Mavericks update.
sudo /Library/StartupItems/VirtualBox/VirtualBox restart
Update: If you’re running the latest 4.3 version of Virtual box the restart command has changed – it’s now;
sudo launchctl load /Library/LaunchDaemons/org.virtualbox.startup.plist
The next ‘vagrant up’ command I ran worked, and my dev environment is back in action.
Update: If you’re still having problems with virtual machine being broken on computer restart..
I know a lot of people are having a similar problem – even if you perform a graceful shutdown of your VM before turning off your mac, on restart your VM is broken again.
Last night I uninstalled and updated VirtualBox to 4.3, did the same to Vagrant, and made sure I had the latest version of Varying Vagrant Vagrants. I then killed my existing virtual machine with ‘vagrant destroy’ which has the effect of downloading a new VM on next ‘vagrant up’. After downloading and installing everything my VM was back up and running.
I then shut down my mac, and restarted. This time a ‘vagrant up’ worked. Or at least it seemed to until I discovered that no sites on the VM responded when I tried to visit them in my brower. I logged into the VM on SSH and checked NGINX – it hadn’t started for some reason, so I restarted the service with ‘service nginx reload’, which worked.
Problem is, still no sites respond.
At present the only way I can get my VM working again after a reboot is to run:
vagrant up --provision
Adding this extra parameter forces vagrant to re-run provisioning of the box which in turn forces all services to start up from scratch. This takes longer than a normal ‘vagrant up’ but it works, so for now it seems to be the best solution!
Update: People are saying that upgrading VirtualBox to the very latest 4.3.2 version has fixed the problem
It hasn’t for me, sadly. I can now start the VM with no issues, but I can’t access any sites on it as NGINX refuses to start properly. Not a VBox problem, more an issue with something in my Varying Vagrant Vagrants config, I suspect. I’m still having to run a ‘vagrant up –provision’ to get going again after a restart.
Let me know in the comments if you’ve found a better way.