Johnny Matthews | Install Vagrant on Windows 11

Vagrant is a useful tool for spinning up local virtual machines, but getting it to run properly on Windows 11 can be a pain. This guide quickly runs through installing it, and spinning up a VM. This was written on 1st of November 2024.

It’s not super complicated; it’s just unclear what you’re meant to do – at least not initially apparent.

Prerequisites

There are a couple of things we need to install before we can start spinning up VMs:

  1. The first step is to install Vagrant. This process is super simple if you just use winget, which is essentially Microsoft’s package manager:

    winget install vagrant
    
  2. Next, we’ll install VirtualBox. Vagrant requires a host virtual machine manager, and VirtualBox is free and easy to use, so we’re gonna use that one:

    winget install Oracle.VirtualBox -v 7.0.6
    

    A quick note here: the maintainers of Vagrant are pretty slow when it comes to updating their software. At the time of writing, Vagrant only supports VirtualBox up to version 7.0.6, while the latest VirtualBox release is at 7.1.4. I’m assuming that the maintainers of Vagrant will update their stuff to support the latest VirtualBox release. Still, for now, we’re stuck specifying which version we want when calling Winget.

  3. Once both Vagrant and VirtualBox are installed, you’ll need to grab the VirtualBox Extension Pack from virtualbox.org/wiki/Downloads.

  4. Open VirtualBox, click File, Tools, Extension Pack Manager.

  5. Click Install and select the Oracle_VirtualBox_Extension_Pack.vbox-extpack file you just downloaded. VirtualBox takes about 2 minutes to install the pack.

Running a VM

We have to follow a few steps to get a VM up and running.

  1. Add the VirtualBox installation location to your current $PATH variable:

    $env:Path += ";C:\Program Files\Oracle\VirtualBox\"
    

    You can add this globally, so you don’t have to run this every time, but that requires dealing with a GUI and/or the registry. I just can’t be bothered doing that.

  2. Create a Vagrantfile. If you’re familiar with Vagrant, then I’m assuming you already know what a Vagrantfile is. If you don’t, go check out the Vagrant docs.

  3. Spin up the VM using vagrant up:

    vagrant up --provider=virtualbox
    

    I’m not sure why, but I only need to add the --provider tag sometimes. This tag tells Vagrant exactly which provider I’m using.

Done

And that’s about it! All in all, it’s not too complicated. There are just some steps that might not be completely obvious.