chore: nicer message to install dependencies (#7715)

If we know how to install all dependencies, then we should recommend
a Playwright CLI one-liner to install dependencies.

References #7682
This commit is contained in:
Andrey Lushnikov 2021-07-19 13:54:42 +03:00 committed by GitHub
parent a8661330de
commit b2c5bfb72c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -175,11 +175,26 @@ export async function validateDependenciesLinux(linuxLddDirectories: string[], d
}
}
const maybeSudo = (process.getuid() !== 0) && os.platform() !== 'win32' ? 'sudo ' : '';
// Happy path: known dependencies are missing for browsers.
// Suggest installation with a Playwright CLI.
if (missingPackages.size && !missingDeps.size) {
throw new Error('\n' + utils.wrapInASCIIBox([
`Host system is missing a few dependencies to run browsers.`,
`Please install them with the following command:`,
``,
` ${maybeSudo}npx playwright install-deps`,
``,
`<3 Playwright Team`,
].join('\n'), 1));
}
// Unhappy path - unusual distribution configuration.
let missingPackagesMessage = '';
if (missingPackages.size) {
missingPackagesMessage = [
` Install missing packages with:`,
` sudo apt-get install ${[...missingPackages].join('\\\n ')}`,
` ${maybeSudo}apt-get install ${[...missingPackages].join('\\\n ')}`,
``,
``,
].join('\n');