playwrightarch-linuxtestinge2e

Playwright on Arch Linux - just use system Chromium

January 5, 2025

So you're on Arch and Playwright is being a pain? Yeah, same. Here's what happens:

bash
$ npm init playwright@latest
BEWARE: your OS is not officially supported by Playwright; installing dependencies for ubuntu24.04-x64 as a fallback.
Installing dependencies...
sh: line 1: apt-get: command not found
Failed to install browsers
Error: Installation process exited with code: 127

Playwright tries to use apt-get. On Arch. Good luck with that.

Even if you skip the auto-install and try manually:

bash
$ npx playwright install chromium
BEWARE: your OS is not officially supported by Playwright; downloading fallback build for ubuntu24.04-x64.

And then when you try to run tests:

bash
$ npx playwright test --ui
Error:
╔═══════════════════════════════════════════════════╗
║ No chromium-based browser found on the system.    ║
║ Please run the following command to download one: ║
║                                                   ║
║     npx playwright install chromium               ║
║                                                   ║
║ <3 Playwright Team                                ║
╚═══════════════════════════════════════════════════╝

You might try installing all the deps manually:

bash
$ sudo pacman -S nss atk cups libxcomposite libxrandr libxdamage \
    libxkbcommon libxfixes libxext libxshmfence mesa alsa-lib \
    pango cairo gtk3 libdrm libxcb libx11 libxss libxtst
# ... all already installed, obviously

Still doesn't work. The bundled Chromium just doesn't play nice with Arch. Library mismatches, missing symbols, the usual Arch-vs-Ubuntu fun.

The fix

Stop fighting it. Just use the Chromium you already have:

bash
sudo pacman -S chromium

(You should already have Chromium installed...right?....right?)

Then tell Playwright to use it in playwright.config.ts:

typescript
{
  name: "chromium",
  use: {
    ...devices["Desktop Chrome"],
    launchOptions: {
      executablePath: "/usr/bin/chromium",
    },
  },
},

That's it. Tests run, life is good.

If you need it to work on CI too

CI boxes are usually Ubuntu, so the bundled browser works fine there. Quick conditional:

typescript
import { existsSync } from "fs";

const chromiumPath = existsSync("/usr/bin/chromium")
  ? "/usr/bin/chromium"
  : undefined;

// then in your project config:
launchOptions: chromiumPath ? { executablePath: chromiumPath } : {},

Firefox works the same way

bash
sudo pacman -S firefox
typescript
launchOptions: {
  executablePath: "/usr/bin/firefox",
},

WebKit though? No standalone browser on Arch. Just test that one in CI.


Tested on Arch (kernel 6.17), Playwright 1.52+, Chromium 138+.