microsoft/playwright · error · Error

Failed to install ${channel}

Error message

Failed to install ${channel}

What it means

Thrown by _installChromiumChannel in the PowerShell branch (Windows) after spawnAsync('powershell.exe', ...) returns a non-zero exit code. The install script (e.g. install_media.ps1) ran but failed, so the channel did not install successfully.

Source

Thrown at packages/playwright-core/src/server/registry/index.ts:1169

    }
    await this._installChromiumChannel(channel, scripts, scriptArgs);
  }

  private async _installChromiumChannel(channel: string, scripts: Record<'linux' | 'darwin' | 'win32', string>, scriptArgs: string[] = []) {
    const scriptName = scripts[process.platform as 'linux' | 'darwin' | 'win32'];
    if (!scriptName)
      throw new Error(`Cannot install ${channel} on ${process.platform}`);
    const cwd = BIN_PATH;
    const isPowerShell = scriptName.endsWith('.ps1');
    if (isPowerShell) {
      const args = [
        '-ExecutionPolicy', 'Bypass', '-File',
        path.join(BIN_PATH, scriptName),
        ...scriptArgs
      ];
      const { code } = await spawnAsync('powershell.exe', args, { cwd, stdio: 'inherit' });
      if (code !== 0)
        throw new Error(`Failed to install ${channel}`);
    } else {
      const shellArgs = scriptArgs.map(a => `'${a.replace(/'/g, `'\\''`)}'`).join(' ');
      const { command, args, elevatedPermissions } = await transformCommandsForRoot([`bash "${path.join(BIN_PATH, scriptName)}" ${shellArgs}`]);
      if (elevatedPermissions)
        console.log('Switching to root user to install dependencies...'); // eslint-disable-line no-console
      const { code } = await spawnAsync(command, args, { cwd, stdio: 'inherit' });
      if (code !== 0)
        throw new Error(`Failed to install ${channel}`);
    }
  }

  async listInstalledBrowsers() {
    const linksDir = path.join(registryDirectory, '.links');
    const { browsers } = await this._traverseBrowserInstallations(linksDir);
    return browsers.filter(browser => fs.existsSync(browser.browserPath));
  }

  private async _validateInstallationCache(linksDir: string) {

View on GitHub (pinned to c8fc3bf8d3)

Solutions

  1. Re-run with elevated permissions (Administrator) so the PowerShell installer can write system paths.
  2. Inspect the PowerShell output above the error for the specific failing step and address it.
  3. Install the browser manually from the vendor site, then launch with the channel.
  4. Retry — transient network failures during the scripted download can cause non-zero exit.
Defensive patterns

Strategy: try-catch

Try / catch

try {
  await runInstall([channel]);
} catch (e) {
  if (/Failed to install/.test(e.message))
    throw new Error(`Channel ${channel} install failed; run an elevated shell and retry`);
  else throw e;
}

Prevention

When it happens

Trigger: Running 'playwright install <chromium-channel>' on Windows where the bundled .ps1 installer exits non-zero — elevation denied, the download URL it was given 404'd, a step in the script errored, or the process was interrupted.

Common situations: Windows CI without admin/elevation rights; the artifact URL passed to the script is stale or unreachable; partial download left a corrupted installer; execution policy blocked the script despite -ExecutionPolicy Bypass.

Related errors


AI-assisted analysis of microsoft/playwright@c8fc3bf8d3 (2026-08-12). Data as JSON: /api/errors/d2cd373d09b8263c. Report an issue: GitHub.