Problems Installing VirtualBox

My first requirement was that I could test all of my work locally using Vagrant before pushing any work to Digital Ocean. Knowing that anything I did locally would then be pushed to Digital Ocean, I decided to start by ensuring that my basic starting provisioning scripts would work locally and remotely before starting to tackle the actual project goals.

A note: I develop on a Linux desktop and a Macbook Pro. Everything I do works on both, but all of my investigative work was done on Linux so the installation of software like Virtualbox and Vagrant and the Hashicorp packages will be slightly different for Mac OS.

Installing VirtualBox

This should have been so easy that it wouldn’t even have warranted more than a passing mention, but no. I started off with

1
sudo apt-get install virtualbox

and that gave me VirtualBox without a GUI. I went to https://www.virtualbox.org/wiki/Downloads to download the .deb and that got me a GUI.

Then I installed vagrant, ran vagrant init followed by vagrant up, and was greeted with

1
2
3
4
5
6
There was an error while executing `VBoxManage`, a CLI used by Vagrant for controlling VirtualBox. The command and stderr is shown below.

Command: ["startvm", "e39b347d-8b5a-4cfc-91a3-74d52566be61", "--type", "headless"]

Stderr: VBoxManage: error: The virtual machine 'ubuntu-xenial-16.04-cloudimg' has terminated unexpectedly during startup with exit code 1 (0x1)
VBoxManage: error: Details: code NS_ERROR_FAILURE (0x80004005), component MachineWrap, interface IMachine

I added the following to my Vagrantfile so I could see exactly what VirtualBox was doing when I ran vagrant up:

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

I ran vagrant up again and got this new error message:

1
RTR3InitEx failed with rc=-1912 (rc=-1912)

I Googled that, and found a Stack Overflow post explaining that I needed to completely purge VirtualBox from my system and reinstall it the downloaded version rather than use the version from apt.

  1. Run sudo dpkg -l | grep virtualbox to see all installed VirtualBox packages.
  2. Run sudo apt-get purge <packagename> for each of those packages.
  3. Reinstall VirtualBox using the previously downloaded .deb file.

I ran vagrant up again and everything worked perfectly.

Side Note

I’m still styling this blog and haven’t finished tackling syntax highlighting for the code blocks yet. Hexo uses highlight.js and I’ve pulled in the Solarized theme but it still needs some tweaking.