{"record":{"id":"78f96facb4f7ea16","repo":"microsoft/playwright","slug":"apt-get-install-s-exited-with-code-code-n","errorCode":null,"errorMessage":"'apt-get install -s' exited with code ${code}:\\n${stderr || stdout}","messagePattern":"'apt-get install -s' exited with code (.+?):\\\\n(.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/playwright-core/src/server/registry/dependencies.ts","lineNumber":134,"sourceCode":"  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[]) {\n  const directoryPaths = windowsExeAndDllDirectories;\n  const lddPaths: string[] = [];","sourceCodeStart":116,"sourceCodeEnd":152,"githubUrl":"https://github.com/microsoft/playwright/blob/c8fc3bf8d31542d59b4d4d9eaab1df93ff541dc6/packages/playwright-core/src/server/registry/dependencies.ts#L116-L152","documentation":"Thrown by reportMissingDependenciesLinux when `apt-get install -s` launches but exits with a non-zero code. The simulation (dry-run) failed, so Playwright cannot determine which packages are missing; stderr or stdout is included to show apt-get's complaint.","triggerScenarios":"apt-get is present but the simulation fails: package lists are out of date (run apt-get update needed), a referenced package is unavailable in configured repositories, repositories are misconfigured, or dpkg is in a broken state.","commonSituations":"Stale apt cache in a Docker image built from a cached layer; disabled/unreachable apt mirrors behind a corporate proxy; a partially upgraded system with held/broken packages; an older image whose package names changed.","solutions":["Run `sudo apt-get update` to refresh package lists, then re-run the Playwright dependency install.","Inspect the captured stderr/stdout in the error to find which package or repository is failing and fix the apt sources.","If on a derivative distro, ensure its repositories actually carry the packages Playwright needs, or switch to the official Playwright image."],"exampleFix":"sudo apt-get update\nsudo npx playwright install-deps\n# or rebuild image layer that caches an out-of-date index","handlingStrategy":"validation","validationCode":"import { execSync } from 'node:child_process';\ntry { execSync('apt-get install -s --no-install-recommends <pkg>', { stdio: 'pipe' }); }\ncatch (e) { console.warn('apt cache may be stale: run apt-get update'); }","typeGuard":null,"tryCatchPattern":"try {\n  await installDeps();\n} catch (e) {\n  if (/apt-get install -s.*exited with code/.test(e.message)) {\n    await run('sudo', ['apt-get', 'update']);\n    await installDeps(); // one retry after refreshing the index\n  } else throw e;\n}","preventionTips":["Run apt-get update in CI before installing Playwright deps.","Rebuild Docker layers that cache stale apt indexes.","Ensure apt sources/mirrors are reachable behind proxies."],"tags":["install","linux","dependencies","apt","system"],"backgroundTag":null,"analyzedSha":"c8fc3bf8d31542d59b4d4d9eaab1df93ff541dc6","analyzedAt":"2026-08-12T07:26:36.950Z","schemaVersion":2},"datasetVersion":"2026-08-12T13:17:24.610Z"}