-
Notifications
You must be signed in to change notification settings - Fork 777
Description
Description
When using --headed mode on Linux with a virtual display (Xvnc, Xvfb), the browser fails to launch because the DISPLAY environment variable is not forwarded to the Chromium subprocess.
Steps to Reproduce
# Start virtual display
Xvnc :99 -geometry 1280x720 -depth 24 &
DISPLAY=:99 openbox &
# This fails
DISPLAY=:99 agent-browser open --headed https://example.comExpected: Browser launches on display :99
Actual: Error "Missing X server or $DISPLAY"
✗ browserType.launch: Target page, context or browser has been closed
╔══════════════════════════════════════════════════════════════════════╗
║ Looks like you launched a headed browser without having a XServer ║
║ running. Set either 'headless: true' or use 'xvfb-run'. ║
╚══════════════════════════════════════════════════════════════════════╝
[pid][err] Missing X server or $DISPLAY
[pid][err] The platform failed to initialize. Exiting.
Root Cause
In dist/browser.js, Playwright's launch() is called without the env option:
// Line ~927
this.browser = await launcher.launch({
headless: options.headless ?? true,
executablePath: options.executablePath,
args: options.args,
});Without env, Playwright doesn't forward environment variables (including DISPLAY) to the browser subprocess.
Suggested Fix
Pass the environment to browser subprocess:
this.browser = await launcher.launch({
headless: options.headless ?? true,
executablePath: options.executablePath,
args: options.args,
env: { ...process.env },
});Same change needed for launchPersistentContext() calls (~lines 897, 913).
Workaround
Launch Chrome manually with DISPLAY set and connect via CDP:
DISPLAY=:99 chrome --remote-debugging-port=9222 --no-sandbox &
agent-browser --cdp 9222 open https://example.comEnvironment
- OS: Ubuntu 24.04
- agent-browser: v0.8.x (compiled binary)
- Display: TigerVNC (Xvnc) on
:99 - Node.js: v24
Related Issues
- --headed mode not working in wsl(ubuntu24.04) #155 (
--headednot working in WSL/Ubuntu) - --headed模式,没有浏览器弹出 #150 (no browser popup in headed mode)
Use Case
AI agents running in cloud VMs need headed mode for visual debugging via VNC/noVNC.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels