Skip to content

Developing with WSL

Jack Gerrits edited this page Jun 1, 2020 · 1 revision

The following will run your through how to build and then debug the VW executable from scratch. [Windows/WSL/VSCode] indicates where this step needs to be done. A lot of these instructions are also relevant when working directly in Ubuntu and other distros.

  1. [Windows] Install WSL
  2. [Windows] Install Ubuntu from Windows Store
  3. [Windows] Install VSCode
  4. [VSCode] Open VSCode and install "Remote - WSL" extension (ms-vscode-remote.remote-wsl)
  5. [WSL] Install dependencies
    • Using apt-get:
      # System deps
      sudo apt install git cmake g++ gdb
      # VW deps
      sudo apt install libboost-dev libboost-thread-dev libboost-program-options-dev libboost-system-dev libboost-math-dev libboost-test-dev zlib1g-dev
  6. [WSL] Clone VW: git clone https://github.com/VowpalWabbit/vowpal_wabbit.git
  7. [WSL] Open VSCode from WSL to start a remote session connected to this directory - code vowpal_wabbit
    • On the first launch it should tell you that it is installing the VSCode remote server
  8. [VSCode] There should now be a VSCode window open and in the bottom left it should indicate it is connected to WSL: Ubuntu
  9. [VSCode] In the open VSCode window connected to the remote install the following two extensions: - "C/C++' (ms-vscode.cpptools) - "Cmake Tools" (ms-vscode.cmake-tools)
  10. [VSCode] Ctrl+Shift+P -> Cmake: Scan for kits
  11. [VSCode] Ctrl+Shift+P -> Cmake: Select a kit -> select one that says Using compilers: C = ..., CXX = ...
  12. [VSCode] Ctrl+Shift+P -> Cmake: build
  13. [VSCode] You can also change this information along the bottom of the window
  14. [VSCode] Ctrl+Shift+P -> Cmake: Set debug target -> vw-bin
  15. [VSCode] Ctrl+Shift+P -> Cmake: Debug

How to change current working directory and command line arguments

  1. [VSCode] Ctrl+Shift+P -> Preferences: Open Settings (JSON)
  2. [VSCode] Add the following to your preferences:
    • cwd can be changed to whatever is needed, but ${workspaceFolder}/test/ is useful as that is the cwd when debugging a test failure.
    • args is an array of strings, you'll need to convert from the raw command line you'd like to use
{
    // ...
    "cmake.debugConfig": {
        "cwd": "${workspaceFolder}/test/",
        "args": [
            "-d",
            "./train-sets/rcv1_small.dat",
        ]
    }
}

How to enable pretty printing of v_array

Replace path/to/ with the absolute path to the base of the cloned VW repo and run the following:

# example: export VW_BASE_DIR=/home/jack/vowpal_wabbit
export VW_BASE_DIR=<change_this_value>
echo "python exec(open('${VW_BASE_DIR}/vowpalwabbit/gdb_pretty_printers.py').read())" >> ~/.gdbinit
Clone this wiki locally