Skip to content

Playwright Browser Download Path Not Configurable via Hermes Install Flow — Forces ~500 MB onto C: #66795

Description

@skyer-flyyy

labels: ["enhancement", "install", "windows"]
project-board: "Hermes-Agent"

📋 Issue: Playwright Browser Download Path Not Configurable via Hermes Install Flow

Problem Statement

When installing Hermes Agent's Desktop application on Windows, the Playwright SDK dependency automatically downloads Chromium (~183 MB), FFmpeg (~1.3 MB), and Chrome Headless Shell (~113 MB) into a hard-coded location: C:\Users\<user>\AppData\Local\ms-playwright\. This totals approximately 500 MB of data written to the system drive (typically C:).

Hermes provides no mechanism—neither in setup.py, setup-hermes.sh, the Desktop installer UI, nor any runtime environment variable—to redirect this download path. While Playwright internally respects PLAYWRIGHT_BROWSERS_PATH (a standard NPM ecosystem variable), Hermes does not pass this through during installation or configure it post-install.

Users with limited C: disk space (e.g., systems where C: has < 10 GB free) cannot relocate these binaries without manual intervention that will be overwritten on every update.

Current Behavior

  1. During installation (pip install hermes-agent + Desktop app setup), npm installs @playwright/test as a transitive dependency.
  2. Playwright's native install script runs automatically, downloading browsers to %LOCALAPPDATA%\ms-playwright\.
  3. No configuration file, CLI flag, or environment variable is read to override this path.
  4. On subsequent updates, the same download/re-install cycle repeats, always targeting C:.

Expected Behavior

  1. Install-time redirection: When running pip install hermes-agent or the Desktop installer, detect and honor the PLAYWRIGHT_BROWSERS_PATH environment variable before triggering browser downloads. If set, browsers are downloaded to the specified directory instead of the default ms-playwright location.
  2. Config file support: Add a section to config.yaml:
    playwright:
      browsers_path: "D:/ms-playwright"  # Optional; defaults to standard location
    Hermes should export this value when invoking any Playwright subprocess.
  3. Desktop UI option: Include a "Browser cache location" path picker in Desktop settings → System/Storage tab, allowing users to change the location at any time without reinstalling.

Root Cause Analysis

  • Playwright's download behavior is controlled entirely by the PLAYWRIGHT_BROWSERS_PATH environment variable (documented at https://playwright.dev/docs/browser-cli#environment-variables).
  • Hermes' setup.py uses tempfile.mkdtemp() for temporary files but does NOT wrap or intercept the Playwright browser install process. There is no code path that reads PLAYWRIGHT_BROWSERS_PATH or configures it before calling npx playwright install.
  • The Electron desktop app also does not expose or manage this variable in its startup sequence.

Code References

  • E:/hermes/hermes-agent/setup.py:31tempfile.mkdtemp(prefix=f"hermes-agent-{kind}-") (only for temp files, not browser binaries)
    --The browser download path for Playwright is controlled by the environment variable PLAYWRIGHT_BROWSERS_PATH. Set this variable before running npx playwright install, and all browser binary packages will be downloaded to the specified directory instead of the default location.
    Default paths:
    Windows: %LOCALAPPDATA%\ms-playwright
    macOS: ~/Library/Caches/ms-playwright/
    Linux: ~/.cache/ms-playwright/
    Example (PowerShell):
    Run $env:PLAYWRIGHT_BROWSERS_PATH="D:\my-browsers" before installation, and the browser path will become D:\my-browsers\ms-playwright\chromium-1228.
  • Install logs confirm the default path: C:/Users/16866/AppData/Local/Temp/hermes-playwright-install-*.log shows downloads going to C:\Users\16866\AppData\Local\ms-playwright\chromium-1228

Suggested Fix Architecture

# In setup.py or an install bootstrap script
import os

def prepare_playwright_environment():
    """Ensure PLAYWRIGHT_BROWSERS_PATH is set before browser download."""
    custom_path = os.environ.get("PLAYWRIGHT_BROWSERS_PATH", "")
    
    if not custom_path:
        # Check config.yaml for a configured path
        try:
            import yaml
            cfg = yaml.safe_load(open(os.path.expanduser("~/.hermes/config.yaml")))
            custom_path = cfg.get("playwright", {}).get("browsers_path", "")
        except Exception:
            pass
    
    # Export for any child processes (including npx/npm which invoke playwright)
    if custom_path:
        os.makedirs(custom_path, exist_ok=True)
        os.environ["PLAYWRIGHT_BROWSERS_PATH"] = custom_path

For the Desktop UI setting, add a Qt/Electron file picker dialog bound to a config key that gets exported as PLAYWRIGHT_BROWSERS_PATH before any Playwright subprocess is launched.


Recommendation Priority

Aspect Effort Impact
Detect/env-pass PLAYWRIGHT_BROWSERS_PATH in install flow Low Critical — solves immediate problem with zero cost
Add playwright.browsers_path to config.yaml Low High — persistent across reboots and updates
Desktop UI path picker Medium Medium — good UX polish for advanced users

This is a one-line-environment-variable-pass-through in most cases. Playwright already supports this natively; Hermes simply needs to not strip it away during installation.

Metadata

Metadata

Assignees

No one assigned

    Labels

    P3Low — cosmetic, nice to havearea/configConfig system, migrations, profilesarea/install-updateInstaller, updater, packaging, wheels, doctorcomp/cliCLI entry point, hermes_cli/, setup wizardcomp/desktopElectron desktop app (apps/desktop/*)platform/windowsNative Windows-specific behavior or breakagesweeper:risk-compatibilitySweeper risk: may break existing users, config, migrations, defaults, or upgradessweeper:risk-platform-windowsSweeper risk: may break or behave differently on native Windowstool/browserBrowser automation (CDP, Playwright)type/featureNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions