apify/crawlee · info
Installing Playwright browsers in an environment where brows
Error message
Installing Playwright browsers in an environment where browsers have already been installed...
What it means
This is a console warning from `InstallPlaywrightBrowsersCommand`. When the environment variable guarding browser installation (indicating browsers were already installed in this environment) is set, the command normally prints 'Browsers are already installed!' and exits. If `--force` was passed, it instead warns that it is reinstalling Playwright browsers into an environment where they already exist. It is informational, not a thrown error.
Source
Thrown at packages/cli/src/commands/InstallPlaywrightBrowsersCommand.ts:35
args.options('force', {
alias: 'f',
default: false,
type: 'boolean',
describe:
'Use `--force` to force installation of browsers even if the environment is marked as having them.',
});
return args as Argv<InstallPlaywrightBrowsersArgs>;
};
handler = (args: ArgumentsCamelCase<InstallPlaywrightBrowsersArgs>) => {
if (process.env[envVariable]) {
if (!args.force) {
console.log(ansiColors.green('Browsers are already installed!'));
return;
}
console.warn(
ansiColors.yellow(
'Installing Playwright browsers in an environment where browsers have already been installed...',
),
);
} else {
console.log(ansiColors.green('Installing Playwright browsers...'));
}
// TODO: detect package manager
execSync(`npx playwright install`, { stdio: 'inherit' });
};
}
View on GitHub (pinned to dbe57fb09c)
Solutions
- If browsers are already correct, drop the `--force` flag — the command will detect the installed browsers and skip.
- If a reinstall is genuinely intended (upgrade/repair), ignore this warning; it confirms the forced re-download is proceeding.
- In CI, cache the Playwright browser path and only force-install when the browser version changed.
Example fix
// before: forced reinstall on every CI run apify install-playwright-browsers --force // after: skip when browsers are already present apify install-playwright-browsers
Defensive patterns
Strategy: validation
Validate before calling
// Check the install marker env var before forcing a reinstall
const alreadyInstalled = Boolean(process.env.APIFY_PLAYWRIGHT_BROWSERS_INSTALLED /* envVariable */);
if (alreadyInstalled && !forceFlag) {
console.log('Browsers are already installed! Skipping.');
return;
} Prevention
- Only pass `--force` when you intend to replace an existing browser installation (upgrade or repair).
- In CI, gate the install step on a cache key that includes the Playwright version so browsers install once.
- Treat this warning as confirmation of an intended reinstall, not a failure.
When it happens
Trigger: Running the install command with the `force` argument/flag set to true while `process.env[envVariable]` (the marker that browsers are already installed) is truthy — i.e. an explicit forced reinstall over an existing installation.
Common situations: CI pipelines re-running the install step with a cached browser environment plus a force flag; developers forcing a reinstall to upgrade or repair Playwright browsers; Docker images where browsers were baked in at build time and a runtime step force-installs again.
Related errors
- Function `newContext()` is not available in incognito mode
- Function `newBrowserCDPSession()` is not available in incogn
- Function `startTracing()` is not available in incognito mode
- Function `stopTracing()` is not available in incognito mode
- A new page can be created with provided context only when us
AI-assisted analysis of apify/crawlee@dbe57fb09c (2026-08-30).
Data as JSON: /api/errors/5fd1e0179c7ecf81.
Report an issue: GitHub.