microsoft/playwright · error · Error

Failed to run 'apt-get install -s' to simulate dependency in

Error message

Failed to run 'apt-get install -s' to simulate dependency install: ${error.message}

What it means

Thrown by reportMissingDependenciesLinux when spawning `apt-get install -s` fails with an error before producing an exit code (the error field of spawnAsync is set). This means the apt-get binary could not be launched at all, as opposed to returning a non-zero code.

Source

Thrown at packages/playwright-core/src/server/registry/dependencies.ts:132

    ...uniqueLibraries,
  ].join(' '));
  const { command, args, elevatedPermissions } = await transformCommandsForRoot(commands);
  if (elevatedPermissions)
    console.log('Switching to root user to install dependencies...'); // eslint-disable-line no-console
  const child = childProcess.spawn(command, args, { stdio: 'inherit' });
  await new Promise<void>((resolve, reject) => {
    child.on('exit', (code: number) => code === 0 ? resolve() : reject(new Error(`Installation process exited with code: ${code}`)));
    child.on('error', reject);
  });
}

async function reportMissingDependenciesLinux(packages: string[]) {
  // `apt-get install -s` simulates the install: it does not need root and does not
  // modify the system. Stdout includes one `Inst <package> ...` line per package
  // that would be installed (i.e. that is currently missing).
  const { code, stdout, stderr, error } = await spawnAsync('apt-get', ['install', '-s', '--no-install-recommends', ...packages], {});
  if (error)
    throw new Error(`Failed to run 'apt-get install -s' to simulate dependency install: ${error.message}`);
  if (code !== 0)
    throw new Error(`'apt-get install -s' exited with code ${code}:\n${stderr || stdout}`);
  const missingPackages: string[] = [];
  for (const line of stdout.split('\n')) {
    const match = /^Inst (\S+) /.exec(line);
    if (match)
      missingPackages.push(match[1]);
  }
  if (!missingPackages.length) {
    console.log('All system dependencies are installed.'); // eslint-disable-line no-console
    return;
  }
  // eslint-disable-next-line no-console
  console.log(`Missing system dependencies (${missingPackages.length}):\n${missingPackages.sort().map(p => `  ${p}`).join('\n')}`);
  process.exitCode = 1;
}

export async function validateDependenciesWindows(sdkLanguage: string, windowsExeAndDllDirectories: string[]) {

View on GitHub (pinned to c8fc3bf8d3)

Solutions

  1. On non-Debian distros, install the required libraries through your package manager manually (apk, dnf, pacman) using the list Playwright documents.
  2. Ensure apt-get exists and is on PATH if you are on a Debian/Ubuntu-based image.
  3. Use the official Playwright Docker image which already has all dependencies pre-installed.

Example fix

# Alpine: apt-get absent -> install deps via apk instead
apk add nss freetype freetype-dev harfbuzz ca-certificates ttf-freefont
# or use the official image
FROM mcr.microsoft.com/playwright:v1.0.0-jammy
Defensive patterns

Strategy: type-guard

Validate before calling

import { existsSync } from 'node:fs';
if (!existsSync('/usr/bin/apt-get'))
  throw new Error('apt-get not available; install deps via your distro package manager');

Type guard

function isAptBased() {
  return existsSync('/usr/bin/apt-get') || existsSync('/usr/bin/apt');
}

Prevention

When it happens

Trigger: Running Playwright's dependency validation on a Linux system where apt-get is not installed (non-Debian distro such as Alpine, Fedora, Arch); apt-get is not on PATH; the spawn itself was denied.

Common situations: Using a minimal/Alpine container where apt-get does not exist; running on a non-Debian distro where Playwright still attempts apt-based detection; misconfigured PATH in a stripped-down image.

Related errors


AI-assisted analysis of microsoft/playwright@c8fc3bf8d3 (2026-08-12). Data as JSON: /api/errors/6b2f392361d42ce0. Report an issue: GitHub.