Agent sandbox redirects PLAYWRIGHT_BROWSERS_PATH and npm_config_devdir to empty cursor-sandbox-cache (Windows) — Playwright reinstall loops + npm 11 warnings

Where does the bug appear (feature/product)?

Cursor IDE

Describe the Bug

Actual

In a sandboxed Agent shell on this machine (observed 2026-08-06):

PLAYWRIGHT_BROWSERS_PATH=C:\Users<user>\AppData\Local\Temp\cursor-sandbox-cache<hash>\playwright
npm_config_devdir=C:\Users<user>\AppData\Local\Temp\cursor-sandbox-cache<hash>\node-gyp
NPM_CONFIG_DEVDIR=C:\Users<user>\AppData\Local\Temp\cursor-sandbox-cache<hash>\node-gyp

Meanwhile the real browsers already exist and work:

%LOCALAPPDATA%\ms-playwright
chromium-1228
chromium_headless_shell-1228
firefox-1532
webkit-2311

Playwright then resolves executables under the empty sandbox path → Executable doesn’t exist → agents re-run playwright install every session even though Chromium is already installed on the host.

npm 11+ emits repeated:

npm warn Unknown env config “devdir”. This will stop working in the next major version of npm.

because Cursor sets npm_config_devdir=…\cursor-sandbox-cache...\node-gyp.

Impact

Wasteful Playwright Chromium re-downloads in Agent sessions (hundreds of MB, minutes of friction)

Agents incorrectly conclude “browsers missing” and burn tokens reinstalling

Noisy npm warnings on nearly every Agent npm/npx invocation

Repo workarounds that sniff cursor-sandbox-cache would couple product code to Cursor internals (we intentionally avoid that)

Suggested fix

Do not override PLAYWRIGHT_BROWSERS_PATH unless the sandbox path is provisioned with the required browser builds — or fall back to the OS default cache when the sandbox dir is empty/missing.

For node-gyp caching, set a node-gyp-specific env var (e.g. whatever node-gyp actually reads), not npm_config_devdir / NPM_CONFIG_DEVDIR, so npm does not treat it as an npm config key.

Ideally: if the host cache already contains the needed Playwright revision, reuse it (read-only) instead of forcing a second install tree under %TEMP%\cursor-sandbox-cache.

Notes

This matches reports on Linux/WSL where Agent sets PLAYWRIGHT_BROWSERS_PATH=/tmp/cursor-sandbox-cache/…/playwright while browsers live in ~/.cache/ms-playwright.

Host terminal outside sandbox: browsers resolve correctly; problem is specific to Agent sandbox env injection.

Steps to Reproduce

On Windows, install Playwright Chromium once into the normal host cache:

%LOCALAPPDATA%\ms-playwright\ (e.g. chromium-1228 present and working outside the Agent)

In Cursor Agent chat, ask the agent to run a shell command that prints:

$env:PLAYWRIGHT_BROWSERS_PATH

$env:npm_config_devdir

whether %LOCALAPPDATA%\ms-playwright exists

Ask the agent to run Playwright E2E / npx playwright test (or inspect chromium.executablePath()).

Separately run npm --version / npm config list in an Agent shell and observe npm warnings about devdir.

Expected Behavior

Agent shells should either:

reuse the existing user Playwright browser cache, or

pre-populate the sandbox Playwright cache when overriding PLAYWRIGHT_BROWSERS_PATH

npm_config_devdir should not be injected as an npm config key. devdir is a node-gyp option; npm 11+ treats unknown npm_config_* keys as warnings (Unknown env config “devdir”).

Operating System

Windows 10/11

Version Information

Cursor version: 3.14.27 (Windows 10/11, win32 10.0.26200)

Area: Agent / sandboxed shell (local Agent tool calls), not Cloud Agent specifically

Repro: any Agent shell command that reads env or runs Playwright / npm

Does this stop you from using Cursor

No - Cursor works, but with this issue

Hey, thanks for the detailed report. With the env dump and the repro steps, it’s immediately clear. This shouldn’t happen, and it’s not something in your setup. In the sandboxed Agent shell on Windows we really do inject PLAYWRIGHT_BROWSERS_PATH pointing to an empty folder in %TEMP%\cursor-sandbox-cache\..., so Playwright can’t see the browsers you already have installed and keeps reinstalling them. The warning Unknown env config "devdir" comes from the same place. I’ve passed this to the team.

For now, the workaround is to override the path inline before running tests. Your env wins over the injected one:

$env:PLAYWRIGHT_BROWSERS_PATH="$env:LOCALAPPDATA\ms-playwright"
npx playwright test

Or put the same value in playwright.config or your project .env so you don’t have to set it manually every time. The devdir warning is harmless for now. It’s just noise and doesn’t break anything.

I don’t recommend using sandbox.json with enableSharedBuildCache: false right now. That opt-out doesn’t work as expected at the moment. I’ll reply here when there’s an update.