[Bug]: Playwright error — Host system is missing dependencies to run browsers
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.
- Clone this repo: https://github.com/dtinth/devbox-playwright-issue
- Enter a shell:
devbox shell - Install deps:
pnpm install - Install browsers:
pnpm playwright install --with-deps - Run test:
pnpm playwright test
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.
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)"
}
}
Additionally, playwright-test just works, it does the above export for you
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)
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.