Skip to content

Default browser config fails when Chrome is not installed - unclear error and workaround #219

@MvRoo

Description

@MvRoo

Problem

When using playwright-cli on a system without Google Chrome installed, the default configuration fails with an unclear error message:

Error: browserType.launchPersistentContext: Chromium distribution 'chrome' is not found at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome
Run "npx playwright install chrome"

The suggested fix (npx playwright install chrome) doesn't work because it installs browsers for a different playwright version than what @playwright/cli uses internally.

Environment

  • macOS (Apple Silicon)
  • @playwright/[email protected] installed globally via npm
  • No Google Chrome installed

Root Cause

The CLI defaults to using the chrome channel, which requires Google Chrome to be installed at a specific path. The bundled Chromium browser is available but not used by default.

Workaround

Setting the PLAYWRIGHT_MCP_BROWSER environment variable works:

PLAYWRIGHT_MCP_BROWSER=chromium playwright-cli open https://example.com

However, this workaround is not documented in --help or the README.

Additional Issue: Browser Version Mismatch

When trying to install browsers, npx playwright install chromium installs for a different playwright version (e.g., 1.58.0) than what @playwright/cli uses (1.59.0-alpha). This causes "browser not installed" errors even after running the suggested install command.

The correct way to install browsers is:

/path/to/node_modules/@playwright/cli/node_modules/playwright/cli.js install chromium

This is not intuitive and not documented.

Suggestions

  1. Better default behavior: Fall back to bundled chromium if the chrome channel is not available, rather than failing
  2. Clearer error message: Include the PLAYWRIGHT_MCP_BROWSER=chromium workaround in the error message
  3. Documentation: Document the PLAYWRIGHT_MCP_BROWSER environment variable in the README and --help output
  4. Browser installation: Document how to install browsers for the specific playwright version bundled with the CLI, or make npx playwright install work correctly

Reproduction Steps

  1. Install @playwright/cli globally: npm install -g @playwright/cli@latest
  2. Ensure Google Chrome is not installed (or rename the app temporarily)
  3. Run: playwright-cli open https://example.com
  4. Observe the error

Expected Behavior

Either:

  • The CLI should fall back to bundled Chromium automatically, or
  • The error message should clearly explain how to use PLAYWRIGHT_MCP_BROWSER=chromium

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions