devbox icon indicating copy to clipboard operation
devbox copied to clipboard

[Bug]: Playwright error — Host system is missing dependencies to run browsers

Open dtinth opened this issue 2 years ago • 4 comments

Current Behavior (bug) When running a Playwright test, browsers won’t run at all. Instead, tests immediately fail with this error message:

Running 2 tests using 1 worker
  1) [chromium] › example.spec.js:4:1 › has title ──────────────────────────────────────────────────

    Error: browserType.launch: 
    ╔══════════════════════════════════════════════════════╗
    ║ Host system is missing dependencies to run browsers. ║
    ║ Missing libraries:                                   ║
    ║     libgobject-2.0.so.0                              ║
    ║     libglib-2.0.so.0                                 ║
    ║     libnss3.so                                       ║
    ║     libnssutil3.so                                   ║
    ║     libsmime3.so                                     ║
    ║     libnspr4.so                                      ║
    ║     libatk-1.0.so.0                                  ║
    ║     libatk-bridge-2.0.so.0                           ║
    ║     libcups.so.2                                     ║
    ║     libgio-2.0.so.0                                  ║
    ║     libdbus-1.so.3                                   ║
    ║     libexpat.so.1                                    ║
    ║     libdrm.so.2                                      ║
    ║     libxcb.so.1                                      ║
    ║     libxkbcommon.so.0                                ║
    ║     libatspi.so.0                                    ║
    ║     libX11.so.6                                      ║
    ║     libXcomposite.so.1                               ║
    ║     libXdamage.so.1                                  ║
    ║     libXext.so.6                                     ║
    ║     libXfixes.so.3                                   ║
    ║     libXrandr.so.2                                   ║
    ║     libgbm.so.1                                      ║
    ║     libpango-1.0.so.0                                ║
    ║     libcairo.so.2                                    ║
    ║     libasound.so.2                                   ║
    ╚══════════════════════════════════════════════════════╝

Expected Behavior (fix) Browsers should run just like in most environments.

Additional context $ devbox version -v

Version:     0.5.11
Platform:    linux_arm64
Commit:      1052c4e37c16ce0df5d60afb8c82076cd290eee8
Commit Time: 2023-08-10T23:32:09Z
Go Version:  go1.20.7
Launcher:    0.2.0

devbox.json https://github.com/dtinth/devbox-playwright-issue/blob/main/devbox.json

To reproduce:

Use a Linux box.

  1. Clone this repo: https://github.com/dtinth/devbox-playwright-issue
  2. Enter a shell:
    devbox shell
    
  3. Install deps:
    pnpm install
    
  4. Install browsers:
    pnpm playwright install --with-deps
    
  5. Run test:
    pnpm playwright test
    

dtinth avatar Aug 23 '23 12:08 dtinth

I'm also trying to get Playwright to run in Devbox.

Relevant Nix packages seem to be playwright-test and playwright-driver. There are instructions here for getting Playwright to work in NixOS, but it's unclear how to translate that across to Devbox. Searching for playwright-driver.browsers gives no results at both https://www.nixhub.io/ and https://search.nixos.org/packages so I don't know how to install that package and obtain a value for PLAYWRIGHT_BROWSERS_PATH.

apgrucza avatar Mar 28 '24 00:03 apgrucza

The following devbox.json let me run playwright cr in a devbox shell and started up chromium:

{
  "packages": [
    "playwright@latest",
    "playwright-driver@latest"
  ],
  "shell": {
    "init_hook": "export PLAYWRIGHT_BROWSERS_PATH=$(nix build --print-out-paths nixpkgs#playwright-driver.browsers)"
  }
}

jnnnnn avatar May 08 '24 05:05 jnnnnn

Additionally, playwright-test just works, it does the above export for you

jnnnnn avatar May 08 '24 05:05 jnnnnn

I met the Missing libraries error in the Github CI. I was adding devbox to the existing setup. Playwright was installed via pnpm.

For me the solution was PLAYWRIGHT_SKIP_VALIDATE_HOST_REQUIREMENTS=true. Playwright started to work again after adding this env var.

(Found it in https://github.com/microsoft/playwright/pull/5806 referenced from https://github.com/microsoft/playwright/issues/5501)

Leksat avatar Sep 09 '24 19:09 Leksat

I have no idea what I'm doing, but unset LD_LIBRARY_PATH just before the playwright install chromium --with-deps and running PW worked for me using NixPacks. Your milage may vary.

rj-au avatar Mar 11 '25 23:03 rj-au