{"record":{"id":"6b2f392361d42ce0","repo":"microsoft/playwright","slug":"failed-to-run-apt-get-install-s-to-simulate-dep","errorCode":null,"errorMessage":"Failed to run 'apt-get install -s' to simulate dependency install: ${error.message}","messagePattern":"Failed to run 'apt-get install -s' to simulate dependency install: (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/playwright-core/src/server/registry/dependencies.ts","lineNumber":132,"sourceCode":"    ...uniqueLibraries,\n  ].join(' '));\n  const { command, args, elevatedPermissions } = await transformCommandsForRoot(commands);\n  if (elevatedPermissions)\n    console.log('Switching to root user to install dependencies...'); // eslint-disable-line no-console\n  const child = childProcess.spawn(command, args, { stdio: 'inherit' });\n  await new Promise<void>((resolve, reject) => {\n    child.on('exit', (code: number) => code === 0 ? resolve() : reject(new Error(`Installation process exited with code: ${code}`)));\n    child.on('error', reject);\n  });\n}\n\nasync function reportMissingDependenciesLinux(packages: string[]) {\n  // `apt-get install -s` simulates the install: it does not need root and does not\n  // modify the system. Stdout includes one `Inst <package> ...` line per package\n  // that would be installed (i.e. that is currently missing).\n  const { code, stdout, stderr, error } = await spawnAsync('apt-get', ['install', '-s', '--no-install-recommends', ...packages], {});\n  if (error)\n    throw new Error(`Failed to run 'apt-get install -s' to simulate dependency install: ${error.message}`);\n  if (code !== 0)\n    throw new Error(`'apt-get install -s' exited with code ${code}:\\n${stderr || stdout}`);\n  const missingPackages: string[] = [];\n  for (const line of stdout.split('\\n')) {\n    const match = /^Inst (\\S+) /.exec(line);\n    if (match)\n      missingPackages.push(match[1]);\n  }\n  if (!missingPackages.length) {\n    console.log('All system dependencies are installed.'); // eslint-disable-line no-console\n    return;\n  }\n  // eslint-disable-next-line no-console\n  console.log(`Missing system dependencies (${missingPackages.length}):\\n${missingPackages.sort().map(p => `  ${p}`).join('\\n')}`);\n  process.exitCode = 1;\n}\n\nexport async function validateDependenciesWindows(sdkLanguage: string, windowsExeAndDllDirectories: string[]) {","sourceCodeStart":114,"sourceCodeEnd":150,"githubUrl":"https://github.com/microsoft/playwright/blob/c8fc3bf8d31542d59b4d4d9eaab1df93ff541dc6/packages/playwright-core/src/server/registry/dependencies.ts#L114-L150","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["On non-Debian distros, install the required libraries through your package manager manually (apk, dnf, pacman) using the list Playwright documents.","Ensure apt-get exists and is on PATH if you are on a Debian/Ubuntu-based image.","Use the official Playwright Docker image which already has all dependencies pre-installed."],"exampleFix":"# Alpine: apt-get absent -> install deps via apk instead\napk add nss freetype freetype-dev harfbuzz ca-certificates ttf-freefont\n# or use the official image\nFROM mcr.microsoft.com/playwright:v1.0.0-jammy","handlingStrategy":"type-guard","validationCode":"import { existsSync } from 'node:fs';\nif (!existsSync('/usr/bin/apt-get'))\n  throw new Error('apt-get not available; install deps via your distro package manager');","typeGuard":"function isAptBased() {\n  return existsSync('/usr/bin/apt-get') || existsSync('/usr/bin/apt');\n}","tryCatchPattern":null,"preventionTips":["On non-Debian distros, install required libs through the native package manager.","Prefer the official Playwright Docker image which bundles all dependencies.","Detect the package manager before invoking dependency tooling."],"tags":["install","linux","dependencies","apt","system"],"backgroundTag":null,"analyzedSha":"c8fc3bf8d31542d59b4d4d9eaab1df93ff541dc6","analyzedAt":"2026-08-12T07:26:36.950Z","schemaVersion":2},"datasetVersion":"2026-08-13T14:17:21.547Z"}