wxt icon indicating copy to clipboard operation
wxt copied to clipboard

WSL runner should check DISPLAY env var before refusing to open browser (WSLg support)

Open 0xBigBoss opened this issue 1 month ago • 2 comments

Description

The WSL runner currently refuses to open browsers unconditionally, but this is outdated given modern WSLg (WSL GUI) support which provides native GUI capabilities with DISPLAY environment variable automatically configured.

Current Behavior

The WSL runner (wsl.mjs) always shows this warning and refuses to open browsers:

WARN  Cannot open browser when using WSL. Load ".output/chrome-mv3-dev" as an unpacked extension manually

This happens even when DISPLAY is set and GUI applications work perfectly.

Expected Behavior

When DISPLAY environment variable is set (indicating WSLg or X11 forwarding), WXT should attempt to open the browser normally instead of refusing.

Environment

  • OS: WSL2 with WSLg on Windows 11
  • DISPLAY: :10.0 (automatically set by WSLg)
  • WXT Version: 0.20.11
  • Browser: Google Chrome in WSL2

Reproduction

  1. Run WXT in WSL2 with WSLg enabled (Windows 11 default)
  2. Run wxt or wxt build
  3. Browser fails to open despite DISPLAY being set and GUI support working

Manual Workaround

Browser opens successfully when launched manually with DISPLAY set:

DISPLAY=:10.0 /usr/bin/google-chrome --load-extension=.output/chrome-mv3-dev

Proposed Solution

Update the WSL runner to check for DISPLAY before refusing:

export function createWslRunner() {
  return {
    async openBrowser() {
      // Check if DISPLAY is set (WSLg/X11 support)
      if (!process.env.DISPLAY) {
        wxt.logger.warn(
          \`Cannot open browser when using WSL without GUI support. Load "\${relative(
            process.cwd(),
            wxt.config.outDir
          )}" as an unpacked extension manually\`
        );
        return;
      }
      
      // DISPLAY is set, delegate to default browser runner
      // (let the normal browser opening logic handle it)
    },
    async closeBrowser() {
    }
  };
}

Related Issues

  • #55 - Original WSL support issue that disabled browser opening entirely
  • This was appropriate at the time, but WSLg (released 2021) changes the situation

Impact

This affects all WSL2 users on Windows 11+ who have WSLg enabled by default. The warning is misleading and forces manual browser loading despite GUI support being fully functional.

0xBigBoss avatar Oct 09 '25 03:10 0xBigBoss

This would be a very welcome change.

infectiousstupidity avatar Nov 05 '25 05:11 infectiousstupidity

Yes please!

Seismix avatar Nov 06 '25 10:11 Seismix