GitHub Copilot in VS Code With WSL 2 USB Forwarding: Compatibility
🔍 WiseChecker

GitHub Copilot in VS Code With WSL 2 USB Forwarding: Compatibility

You want to use GitHub Copilot in VS Code while working inside a WSL 2 environment, and you need USB forwarding for devices like microcontrollers, flash drives, or security keys. The problem is that WSL 2 does not natively support USB device passthrough, and standard USB forwarding tools can interfere with Copilot’s remote connection. This article explains how GitHub Copilot, VS Code, and WSL 2 with USB forwarding interact, and what compatibility issues you may face. You will learn the exact setup steps, known limitations, and how to avoid common failures.

Key Takeaways: GitHub Copilot in WSL 2 with USB Forwarding

  • VS Code Remote – WSL extension: Required to connect VS Code to the WSL 2 environment where Copilot runs.
  • usbipd-win tool: The only officially supported method for USB device forwarding into WSL 2.
  • Copilot extension in WSL remote window: Must be installed inside the WSL 2 distro, not on the Windows host, for Copilot to see USB devices.

ADVERTISEMENT

How GitHub Copilot, VS Code, and WSL 2 USB Forwarding Work Together

GitHub Copilot is an AI code completion tool that runs as a VS Code extension. When you open a WSL 2 remote window in VS Code, the Copilot extension communicates with the GitHub Copilot service through the WSL 2 network stack. USB forwarding in WSL 2 is handled by the usbipd-win project, which attaches a physical USB device from the Windows host to a WSL 2 distro. The forwarded device appears as a Linux device file inside the distro, such as /dev/ttyUSB0 for a serial adapter.

The compatibility concern arises because Copilot’s extension in VS Code runs in the context of the remote WSL environment. If the Copilot extension is installed on the Windows side only, it cannot see the USB devices forwarded into WSL 2. The fix is to install the Copilot extension inside the WSL 2 distro. Additionally, USB forwarding itself can cause network interruptions if the forwarded device is a network adapter or a device that triggers kernel driver conflicts. For most USB devices like storage or serial devices, Copilot functions normally after the extension is correctly placed.

Prerequisites

Before you start, you need the following items installed and configured:

  • Windows 10 version 2004 or later, or any Windows 11 build
  • WSL 2 enabled with a Linux distro installed such as Ubuntu 22.04
  • VS Code installed on Windows with the Remote – WSL extension
  • usbipd-win version 4.0.0 or later installed on the Windows host
  • A GitHub account with an active Copilot subscription

Steps to Set Up GitHub Copilot in VS Code with WSL 2 USB Forwarding

Follow these steps in order. Do not skip the extension installation step inside WSL 2.

  1. Install usbipd-win on Windows
    Download the latest MSI installer from the usbipd-win GitHub releases page. Run the installer and restart your computer. After restart, open a PowerShell terminal as administrator and run usbipd list to verify the service is running. You should see a list of USB devices attached to your Windows host.
  2. Attach the USB device to WSL 2
    In the same administrator PowerShell, run usbipd bind --busid X-X where X-X is the bus ID of your device from the list. Then run usbipd attach --wsl --busid X-X. The device is now forwarded to your default WSL 2 distro. Verify with lsusb inside the WSL terminal.
  3. Open VS Code and connect to WSL 2
    Launch VS Code on Windows. Press Ctrl+Shift+P to open the command palette. Type Remote-WSL: Open Folder in WSL and select your WSL 2 distro. VS Code reloads into a remote window connected to the WSL environment.
  4. Install the GitHub Copilot extension inside WSL 2
    In the VS Code remote window, go to the Extensions view by pressing Ctrl+Shift+X. Search for GitHub Copilot. You will see an Install button with a note saying Install in WSL: Ubuntu. Click that button. The extension installs inside the WSL 2 distro, not on the Windows host. After installation, reload the window when prompted.
  5. Sign in to GitHub Copilot
    After reload, click the Copilot icon in the status bar. Follow the sign-in prompts. A browser window opens for GitHub authentication. Once signed in, Copilot activates. You can test it by opening a Python or JavaScript file and typing a comment like // function to read USB serial data. Copilot should suggest code completions.
  6. Verify USB device access from Copilot code
    Write a small script that opens the USB device file, for example using PySerial for serial devices. Run the script from the VS Code integrated terminal inside WSL 2. Copilot will suggest relevant library calls and error handling. If the device file is accessible, Copilot works correctly.

ADVERTISEMENT

Common Compatibility Issues and Their Fixes

Copilot does not appear in VS Code after USB device attach

This happens when the Copilot extension is installed on the Windows host only, not inside the WSL 2 remote window. The fix is to uninstall the extension on the host and reinstall it from within the WSL 2 remote window as shown in step 4 above. After reinstallation, Copilot appears in the status bar.

USB device attached but not visible inside WSL 2

The usbipd-win attach command might fail if the device is already bound to another driver on Windows. Run usbipd bind --force --busid X-X to force bind the device. If the device is a USB network adapter, WSL 2 may reject it because network adapters can conflict with the virtual switch. Use a different USB device type for development.

Copilot autocomplete stops after USB forwarding

This is rare but can occur if the forwarded USB device is a storage device that causes the WSL 2 kernel to remount filesystems. The Copilot extension may temporarily lose connection to the GitHub service. Wait 30 seconds and then press Ctrl+Shift+P and run Developer: Reload Window. Copilot reconnects automatically.

VS Code remote window freezes when attaching USB device

The freeze occurs because the usbipd-win service interrupts the WSL 2 network stack during device attach. This is a known limitation. To avoid it, attach the USB device before opening VS Code. If the freeze happens, close VS Code, detach the device with usbipd detach --busid X-X, reattach, and then open VS Code again.

GitHub Copilot in WSL 2 vs Native Windows: Compatibility Comparison

Item WSL 2 with USB Forwarding Native Windows
Copilot extension location Must be installed inside WSL 2 distro Installed on Windows host
USB device access Requires usbipd-win bind and attach Native Windows drivers handle devices
Network stability during attach Possible brief freeze of VS Code remote window No impact
Device types supported Serial, storage, HID; no network adapters All USB device types
Copilot latency Same as native Windows Same

You can now run GitHub Copilot in VS Code with WSL 2 and USB forwarding for development tasks like firmware flashing or serial debugging. The key step is installing the Copilot extension inside the WSL 2 remote window. For best stability, attach USB devices before launching VS Code. If you work with USB network adapters, use native Windows instead of WSL 2 for Copilot sessions.

ADVERTISEMENT