microsoft/playwright · error · Error
'apt-get install -s' exited with code ${code}:\n${stderr ||
Error message
'apt-get install -s' exited with code ${code}:\n${stderr || stdout} What it means
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.
Source
Thrown at packages/playwright-core/src/server/registry/dependencies.ts:134
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[]) {
const directoryPaths = windowsExeAndDllDirectories;
const lddPaths: string[] = [];View on GitHub (pinned to c8fc3bf8d3)
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.
Example fix
sudo apt-get update sudo npx playwright install-deps # or rebuild image layer that caches an out-of-date index
Defensive patterns
Strategy: validation
Validate before calling
import { execSync } from 'node:child_process';
try { execSync('apt-get install -s --no-install-recommends <pkg>', { stdio: 'pipe' }); }
catch (e) { console.warn('apt cache may be stale: run apt-get update'); } Try / catch
try {
await installDeps();
} catch (e) {
if (/apt-get install -s.*exited with code/.test(e.message)) {
await run('sudo', ['apt-get', 'update']);
await installDeps(); // one retry after refreshing the index
} else throw e;
} Prevention
- 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.
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- Failed to run 'apt-get install -s' to simulate dependency in
- Failed to install windows dependencies!
- Host system is missing dependencies!\n\n${details.join('\n')
- Failed to install WebKit via WSL
- Missing system dependencies required to run browser ${browse
AI-assisted analysis of microsoft/playwright@c8fc3bf8d3 (2026-08-12).
Data as JSON: /api/errors/78f96facb4f7ea16.
Report an issue: GitHub.