Skip to content

[CLI]: attach --extension can't find Windows-host extension on WSL2; working config needs undocumented env vars #42092

Description

@0anton

What's going on

On WSL2, playwright-cli attach --extension=<browser> cannot discover the Playwright Extension running in a Windows Chrome/Edge, and the config that does work relies on undocumented environment variables (there are no CLI flags for it). This is a WSL host/guest split: the CLI runs in the Linux guest, but the only browser with the extension installed is the Windows host browser.

1. Misleading failure with the documented flags

Running exactly what the docs describe (extension installed in Windows Chrome, token from the extension status page):

export PLAYWRIGHT_MCP_EXTENSION_TOKEN='<token>'
npx -y @playwright/cli@latest attach --extension=chrome

fails with:

Error: Playwright Extension not found in "/home/<user>/.config/google-chrome".
Install it from https://chromewebstore.google.com/detail/playwright-extension/mmlmfjhmonkocbjadbfplnigmagldckm
    at createExtensionBrowser (.../playwright-core/lib/coreBundle.js)
    at async createBrowserWithInfo (...)
Error: Daemon pid=<pid>: Daemon process exited with code 1

The extension is installed — just in the Windows Chrome profile, not the Linux profile ~/.config/google-chrome that the CLI checks. The error message is misleading: it tells the user to install an extension that is already installed, and gives no hint that a Windows profile / host browser is involved.

2. The working configuration requires undocumented env vars

attach only exposes --cdp, --endpoint, --extension, --config, --session (per playwright-cli --help attach). There is no --executable-path and no --user-data-dir flag. The only way to point it at the Windows browser is via env vars that aren't documented for this flow:

export PLAYWRIGHT_MCP_EXTENSION_TOKEN='<token>'
export PLAYWRIGHT_MCP_BROWSER='chrome'
export PLAYWRIGHT_MCP_EXECUTABLE_PATH='/mnt/c/Program Files/Google/Chrome/Application/chrome.exe'
export PWTEST_EXTENSION_USER_DATA_DIR='/mnt/c/Users/<user>/AppData/Local/Google/Chrome/User Data'
npx -y @playwright/cli@latest attach --extension=chrome --session=demo

With these set, it works correctly:

### Session `demo` created, attached to `chrome`.
### Page
- Page URL: chrome-extension://mmlmfjhmonkocbjadbfplnigmagldckm/connect.html?mcpRelayUrl=ws%3A%2F%2F127.0.0.1%3A41791%2Fextension%2F...&token=&lt;redacted&gt;
- Page Title: Welcome
### Snapshot
- [Snapshot](.playwright-cli/page-...yml)

Two problems here:

  • PWTEST_EXTENSION_USER_DATA_DIR looks like an internal test variable, yet it is the only knob that makes the extension flow work on WSL. If it is the supported mechanism, it should be documented (and ideally surfaced as a proper --user-data-dir flag on attach). If not, there should be a supported flag.
  • The relay URL is now correctly IPv4 (ws://127.0.0.1:...), so the earlier IPv6 issue [Bug]: WSL extension relay emits IPv6 loopback URL unreachable from Windows Edge #41180 appears fixed. This report is about the earlier extension-discovery step, not the relay URL.

Expected behavior

  • On WSL2, attach --extension should be able to target a Windows host browser without relying on PWTEST_* env vars — e.g. via documented --executable-path / --user-data-dir flags on attach.
  • When the extension genuinely can't be found, the error should mention which profile/path was checked and note the WSL host-browser case, rather than unconditionally telling the user to install an already-installed extension.

Environment

  • OS: Windows 11 + WSL2 (Linux 6.6.87.2-microsoft-standard-WSL2)
  • Browser with extension: Windows Chrome, Playwright Extension installed
  • Node: v24.14.1, npx 11.11.0

Note on package naming (separate, minor)

npx playwright-cli (the bare package name) resolves to playwright-cli@0.262.0 / playwright-core@1.59.0-alpha-*, which has no attach command at all (Unknown command: attach) — yet its bundled SKILL.md documents attach --extension. The actively maintained CLI is @playwright/cli@0.1.17. Users following the skills docs with the bare playwright-cli package hit a dead end. Consider deprecating/redirecting the playwright-cli npm package to @playwright/cli.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions