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

  1. If browsers are already correct, drop the `--force` flag — the command will detect the installed browsers and skip.
  2. If a reinstall is genuinely intended (upgrade/repair), ignore this warning; it confirms the forced re-download is proceeding.
  3. 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

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


AI-assisted analysis of apify/crawlee@dbe57fb09c (2026-08-30). Data as JSON: /api/errors/5fd1e0179c7ecf81. Report an issue: GitHub.