Running VS Code Agents in WSL Using WSLg

May 15, 2026

Running VS Code Agents in WSL Using WSLg

The Problem

The new Visual Studio Code Agents app (the standalone GitHub “Agents” product) does not yet support WSL remote connections. If you work primarily in WSL2 with your repos on the Linux filesystem, you are stuck: the Agents app runs on Windows and cannot open WSL directories properly. UNC paths via \\wsl.localhost cause file-attribute confusion, CR/LF issues, and the integrated terminal does not spawn a proper WSL shell.

This is tracked in microsoft/vscode#307568.

The Workaround: Run VS Code Agents Natively in WSL via WSLg

Since WSL2 with WSLg supports running Linux GUI applications that render on the Windows desktop, you can run the Linux build of VS Code Agents directly inside your WSL distro. This sidesteps the remote-connection problem entirely because the editor is running natively on Linux, right where your files are.

Step 1: Download the Linux Build

Download the Linux x64 .tar.gz archive of VS Code (or VS Code Insiders / Agents build) and extract it to a location that is not on your $PATH:

mkdir -p "$HOME/bin"
cd $HOME/bin
curl -OL 'https://code.visualstudio.com/sha/download?build=stable&os=linux-x64'
# Download and extract (adjust URL for the Agents/Insiders build)
tar -xzf code-stable-x64.tar.gz -C "$HOME/bin/"

This gives you $HOME/bin/VSCode-linux-x64/code. Do not add $HOME/bin/VSCode-linux-x64 to your $PATH. Keeping it off the path avoids conflicts with the Windows code command that the regular VS Code installation exposes at /mnt/c/Users/<USERNAME>/AppData/Local/Programs/Microsoft VS Code/bin/code.

Step 2: Create a Shell Function

Add the following function to your ~/.bashrc or ~/.zshrc:

lcode() {
  local logfile="/tmp/lscode-$(date +%Y%m%d-%H%M%S)-$$.log"
  DBUS_SESSION_BUS_ADDRESS="disabled:" /home/cicorias/bin/VSCode-linux-x64/code --disable-gpu "$@" >"$logfile" 2>&1 &
  disown
}

Troubleshooting

look in /tmp/lcode* log files

If you get errors looking for libs (look in /tmp/lcode* log files) need to add couple of libs

#for ubuntu 24.04
sudo apt-get install libnspr4 libnss3 libasound2t64

A few things to note:

Step 3: Use It

# Open the current directory
lcode .

# Open a specific project
lcode ~/projects/my-repo

The VS Code Agents window renders on your Windows desktop via WSLg, but the editor process and all file I/O happen natively on the Linux filesystem. Extensions, the integrated terminal, and Git all work as expected because everything is running inside WSL.

Why This Works

WSLg provides a Wayland/X11 compositor that bridges Linux GUI apps to the Windows desktop. By running the Linux build of VS Code Agents inside WSL, the editor sees a normal Linux environment. There is no remote connection, no UNC path translation, and no cross-OS filesystem boundary. Your files, your shell, and your tools are all in one place.

Also Works with the GitHub Copilot App

GitHub announced the GitHub Copilot app on May 14, 2026. It is a standalone desktop application for agent-driven development that brings parallel workstreams, GitHub integration, and PR lifecycle management into one place. It is separate from VS Code but built on the same Electron/Chromium stack.

The Linux build is available as an AppImage from the github/app releases page. The same WSLg technique described above works for it as well. Download the Linux x64 AppImage, make it executable, and create a similar shell function:

ghapp() {
  local logfile="/tmp/ghapp-$(date +%Y%m%d-%H%M%S)-$$.log"
  DBUS_SESSION_BUS_ADDRESS="disabled:" /home/cicorias/bin/GitHub-Copilot-linux-x64.AppImage --disable-gpu "$@" >"$logfile" 2>&1 &
  disown
}

The same flags apply: disabled: for the D-Bus session bus, --disable-gpu for reliable rendering under WSLg, and /tmp log redirection for debugging.

References


Recent Posts

Older Posts