Skip to content

feat(deps): add native Fedora Linux support#39665

Closed
CybLow wants to merge 1 commit intomicrosoft:mainfrom
CybLow:feat-fedora-support
Closed

feat(deps): add native Fedora Linux support#39665
CybLow wants to merge 1 commit intomicrosoft:mainfrom
CybLow:feat-fedora-support

Conversation

@CybLow
Copy link
Copy Markdown

@CybLow CybLow commented Mar 13, 2026

Summary

This PR adds native Fedora Linux support to Playwright. Currently, Playwright only supports Debian/Ubuntu-based distributions — running on Fedora fails because:

  • install-deps hardcodes apt-get (Fedora uses dnf)
  • No Fedora RPM package mappings exist
  • Error messages reference apt-get install instead of dnf install

Fedora is the 3rd most popular Linux distribution and the upstream for RHEL/CentOS/Rocky/Alma. This PR makes Chromium and Firefox work natively on Fedora with zero workarounds.

What this PR does

Platform detection (hostPlatform.ts, linuxUtils.ts):

  • Detects Fedora via /etc/os-releasefedora-x64 / fedora-arm64
  • Adds id_like field to os-release parsing (for future RHEL-family detection)
  • Versionless platform string (Fedora packages are stable across versions 39–43+, and versions have short 13-month lifecycles unlike Ubuntu LTS)
  • isOfficiallySupportedPlatform: false (browsers are Ubuntu-built binaries)

Package management (dependencies.ts):

  • getLinuxPackageManager() helper: returns 'dnf' for Fedora, 'apt' otherwise
  • installDependenciesLinux(): uses dnf install -y --skip-unavailable on Fedora
  • validateDependenciesLinux(): shows dnf install in error messages
  • Validation correctly separates compat-layer libs from regular missing deps:
    • Compat-only missing → warns with install-deps guidance (doesn't block Chromium/Firefox)
    • dlopen-only libs (e.g. libx264.so from RPM Fusion) → warns, doesn't block browser launch
    • Truly required ldd deps missing → throws with correct dnf package suggestions

Browser downloads (index.ts):

  • Adds fedora-x64 and fedora-arm64 to all DOWNLOAD_PATHS records
  • Chromium/Firefox: reuses Ubuntu 24.04 builds (these binaries work cross-distro)
  • WebKit: also uses Ubuntu 24.04 builds (see WebKit section below)

Native dependencies (nativeDeps.ts):

  • Complete fedora-x64 entry with correct Fedora RPM package names for tools, chromium, firefox, webkit
  • 70+ lib2package mappings (.so names → Fedora RPM package names)
  • Tool deps include curl, binutils, tar, findutils (needed by compat layer)
  • fedora-arm64 spread variant

WebKit on Fedora — discussion needed

WebKit binaries are compiled on Ubuntu 24.04, which means they link against Ubuntu's library versions. On Fedora, several libraries have ABI-incompatible versions:

Library Ubuntu 24.04 (what WebKit expects) Fedora 43 (what system has)
libjpeg libjpeg.so.8 (LIBJPEG_8.0 ABI) libjpeg.so.62 (LIBJPEG_6.2 ABI)
ICU libicudata.so.74 (ICU 74) libicudata.so.75+ (ICU 75–77)
libjxl libjxl.so.0.8 (soversion 0.8) libjxl.so.0.11 (soversion 0.11)

This cannot be fixed in TypeScript — it's baked into the compiled C++ binary. This PR includes a compatibility layer (fedoraCompat.ts) that:

  1. Downloads Ubuntu 24.04's libjpeg-turbo8 .deb → extracts libjpeg.so.8 with LIBJPEG_8.0 symbols (HTTPS, architecture-aware)
  2. Downloads Ubuntu 24.04's libicu74 .deb → extracts ICU 74 libraries
  3. Creates a libjxl.so.0.8 symlink → system's libjxl.so.0.11
  4. Patches WebKit MiniBrowser wrapper scripts to include compat libs in LD_LIBRARY_PATH
  5. Compat libraries auto-install during both playwright install-deps and playwright install webkit
  6. Idempotent wrapper patching via dedicated # playwright-fedora-compat-patched marker (works regardless of custom PLAYWRIGHT_COMPAT_DIR)
  7. Full error handling with warnings on all failure paths

All compat libraries are installed to ~/.local/lib/playwright-compat/ (user-scoped, non-invasive).

I understand this compat layer may not align with the project's architecture and the team may prefer a different approach. Possible alternatives:

  1. Remove WebKit support for Fedora entirely — set download path to undefined, ship Chromium + Firefox only. Clean and honest.
  2. Add Fedora to the WebKit build matrix — build webkit-fedora.zip on Fedora CI, which would eliminate all ABI issues. This is the proper long-term fix.
  3. Keep the compat layer — it works and is tested, but adds complexity.

I'm happy to strip fedoraCompat.ts and remove WebKit support from this PR if the team prefers option 1, and then open a follow-up issue requesting Fedora WebKit builds.

What this gives Fedora users

# These work natively:
npx playwright install-deps        # uses dnf, installs correct RPM packages
npx playwright install chromium     # downloads and works
npx playwright install firefox      # downloads and works

# Chromium and Firefox API works:
const { chromium, firefox } = require('playwright');
const browser = await chromium.launch();  // works
const browser = await firefox.launch();   // works
const browser = await webkit.launch();    // works (via compat layer)

Design decisions

Decision Choice Rationale
Platform string fedora-x64 (versionless) Fedora packages are stable across versions, and versions have short 13-month lifecycles
Officially supported false Browsers are Ubuntu-built binaries
Package manager detection Check platform string prefix Simpler and more reliable than probing filesystem
RHEL/CentOS/Rocky/Alma Not included Different package versions — separate contribution if needed

Testing

Tested on a clean Fedora 43 Docker container (no pre-installed dev tools, no env var workarounds):

  • Platform detected as fedora-x64
  • install-deps uses dnf with correct packages
  • Chromium: 22 API tests passed (launch, navigate, JS eval, DOM, screenshots, viewport, cookies, network interception, locators, video, tracing, HAR, device emulation, etc.)
  • Firefox: 18 API tests passed
  • WebKit: 18 API tests passed (via compat layer)
  • CLI: 9 tests passed (screenshots, PDF generation, version, clear-cache)
  • Total: 70 passed, 0 failed

See also: playwright-fedora — standalone Fedora integration testing repo with Docker-based test suite.

Test plan

  • npm run flint passes (ESLint + tsc clean, doclint failure is pre-existing — requires browser binaries installed)
  • Test on Fedora 43 Docker: npx playwright install-deps uses dnf
  • Test on Fedora 43 Docker: Chromium launch + full API test suite
  • Test on Fedora 43 Docker: Firefox launch + full API test suite
  • Test on Fedora 43 Docker: WebKit launch + full API test suite (via compat layer)
  • Test on Fedora 43 Docker: CLI commands (screenshots, PDF, version)
  • Verify TypeScript Record<HostPlatform, ...> completeness (all DOWNLOAD_PATHS include fedora entries)
  • No regressions on Ubuntu/Debian (no code paths changed for existing platforms)

Add Fedora as a recognized platform in Playwright with full support for
Chromium and Firefox, and experimental WebKit support via a compatibility
layer.

Platform detection:
- Detect Fedora via /etc/os-release (fedora-x64, fedora-arm64)
- Add id_like field to os-release parsing for future RHEL-family detection
- Versionless platform string (packages stable across Fedora 39-43+)
- isOfficiallySupportedPlatform: false (browsers are Ubuntu-built)

Package management:
- Use dnf install -y --skip-unavailable instead of apt-get on Fedora
- Add complete Fedora RPM package mappings for all three browsers
- Add 70+ lib2package mappings (.so names -> Fedora RPM package names)
- Show correct dnf install commands in error messages
- On Fedora, warn instead of throwing when all missing deps have known
  package mappings (graceful degradation for non-critical libs)

Browser downloads:
- Add fedora-x64 and fedora-arm64 to all DOWNLOAD_PATHS records
- Chromium/Firefox: reuse Ubuntu 24.04 builds (cross-distro compatible)
- WebKit: reuse Ubuntu 24.04 builds with compat layer (see below)

WebKit compatibility layer (fedoraCompat.ts):
- Downloads Ubuntu 24.04 libjpeg-turbo8 .deb for LIBJPEG_8.0 ABI
- Downloads Ubuntu 24.04 ICU 74 .deb for ICU symbol compatibility
- Creates libjxl.so.0.8 symlink to system libjxl for soversion compat
- Patches WebKit MiniBrowser wrapper scripts with compat LD_LIBRARY_PATH
- Architecture-aware (amd64/arm64) for .deb downloads and extraction
- All compat libraries installed to ~/.local/lib/playwright-compat/
- Full error handling with warnings on all failure paths

Note: The compat layer is experimental. The proper long-term fix is adding
Fedora to the WebKit build matrix in the CI infrastructure. The team may
prefer to ship Chromium+Firefox only and set WebKit to undefined.
CybLow pushed a commit to CybLow/playwright-fedora that referenced this pull request Mar 13, 2026
- Replace libjpeg cmake/gcc/nasm build with Ubuntu .deb download
- Add deb_arch() helper for arm64/amd64 architecture detection
- Use HTTPS URLs instead of HTTP for all Ubuntu package downloads
- Remove launchpadlibrarian.net fallback (hardcoded amd64 ID)
- Remove cmake/gcc/gcc-c++/nasm from Dockerfile deps
- Add libjxl base compat dir to WebKit wrapper patching
- Reference upstream PR microsoft/playwright#39665
- No compiler toolchain required — only curl/binutils/tar/findutils
@yury-s
Copy link
Copy Markdown
Member

yury-s commented Mar 17, 2026

This is out of scope at the moment.

@yury-s yury-s closed this Mar 17, 2026
@CybLow
Copy link
Copy Markdown
Author

CybLow commented Mar 17, 2026

This is out of scope at the moment.

what part is out of scope exactly? Fedora are a huge developper base os. It's the support in general, or specifically the WebKit compat layer?
Asking because Chromium and Firefox just work, no hacks involved. The only messy part is WebKit, and that’s entirely a CI problem (Ubuntu-built binaries + ABI mismatch). I’m happy to strip that out completely and keep this PR to Chromium + Firefox only.
Also worth noting Fedora is upstream of RHEL, Rocky, and Alma. Right now those users run npx playwright install-deps and get told to run apt-get install. That command doesn’t even exist on their system.
If dropping WebKit makes this mergeable, I can have a clean PR up quickly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants