Skip to content

Guide: Developing Vector on Windows on AWS

Jonathan Padilla edited this page Mar 23, 2023 · 15 revisions

This is a brief guide to developing Vector on Windows via an EC2 Windows VM.

The CI that builds Vector on Windows uses the Github runner with the following installed software, this allows us to run unix commands and use the scripts in the scripts.

Note: The CI runs WSL, it won't be possible to run WSL in EC2 since EC2 itself is a Virtual Machine

Note: It may be possible to set the git bash path to $env:PATH to continue with this AWS setup

Set up AWS Instance

  • Create an EC2 instance with Windows server 2019 or 2022.
    • A t2.2xlarge with at least 120gb storage works well.
    • You will need to use Remote Desktop to connect to the machine.
    • Assign a keypair to the instance which you can use to decrypt the RDP Administrator password.

Set up Developer Environment

  1. Install Microsoft C++ Build Tools from here: Microsoft C++ Build Tools - Visual Studio

    • Select Desktop Development with C++.
    • From Individual Components select C++ Clang compiler for Windows.
    • From Individual Components select MSBuild support for LLVM (clang-cl) toolset. This may get more than you need, but it works.
  2. To install Rust, install rustup-init.exe from:

  3. Install git from Git - Downloading Package

  4. Install chocolatey by pasting this into a PowerShell terminal:

Set-ExecutionPolicy Bypass -Scope Process -Force; [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; iex ((New-Object System.Net.WebClient).DownloadString('https://community.chocolatey.org/install.ps1'))
  1. Install cmake from Download

  2. Install perl from Strawberry Perl for Windows

  3. Git clone the Vector project (using git bash). In a PowerShell window, cd to the Vector folder and run:

.\scripts\environment\bootstrap-windows-2019.ps1

Note: You will get some errors about FilePath being null. This doesn’t seem to stop things working.

Build

Since we are building Vector on Windows we must use the appropriate feature set

cargo build --no-default-features --features default-msvc, cargo test, cargo check should now work.

Note: If having errors with Building, see 2022 Build Tools Path Update for troubleshooting


2022 Build Tools Path Update

When using Microsoft Visual Studio Build Tools 2022 it seems like the PATH is not properly updated. You may want to try the below commands in PowerShell:

  1. Open PowerShell with Administrator Privileges

  2. Set the environment variables to use the BuildTools PATH

cmd.exe /c "`"C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\VC\Auxiliary\Build\vcvars64.bat`" && set"
  1. Set the LLVM and Clang PATH
$env:PATH += ";C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\VC\Tools\Llvm\x64\bin"

Visual Studio Code Set up

Install the below extensions

  1. CodeLLDB (vadimcn.vscode-lldb)

  2. Rust-Analyzer (rust-lang.rust-analyzer)

  3. crates (serayuzgur.crates)

  4. Better TOML (bungcip.better-toml)

Rust analyzer will not function properly since it will not use the correct feature set.

  1. Press Ctrl + Shift + P and open User Settings (JSON)
  2. Paste the below settings for Rust-Analyzer:
"rust-analyzer.cargo.noDefaultFeatures": true,
    "rust-analyzer.cargo.features": [
        "default-msvc"
    ]