Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature]: Support picking platform when installing --with-deps #34255

Closed
GammaGames opened this issue Jan 8, 2025 · 3 comments
Closed

[Feature]: Support picking platform when installing --with-deps #34255

GammaGames opened this issue Jan 8, 2025 · 3 comments

Comments

@GammaGames
Copy link

GammaGames commented Jan 8, 2025

🚀 Feature Request

Allow a user to pick the target platform when installing. apt has all the packages, here's a script that loops through the deps and checks if they can install:

#!/usr/bin/env bash

function _search() {
    for package in "$@"; do
        apt-get install --dry-run $package 1> /dev/null
    done
}

echo "20.04"
echo "Checking tools..."
_search "xvfb" "fonts-noto-color-emoji" "ttf-unifont" "libfontconfig" "libfreetype6" "xfonts-cyrillic" "xfonts-scalable" "fonts-liberation" "fonts-ipafont-gothic" "fonts-wqy-zenhei" "fonts-tlwg-loma-otf" "ttf-ubuntu-font-family"
echo "Checking chromium..."
_search "fonts-liberation" "libasound2" "libatk-bridge2.0-0" "libatk1.0-0" "libatspi2.0-0" "libcairo2" "libcups2" "libdbus-1-3" "libdrm2" "libegl1" "libgbm1" "libglib2.0-0" "libgtk-3-0" "libnspr4" "libnss3" "libpango-1.0-0" "libx11-6" "libx11-xcb1" "libxcb1" "libxcomposite1" "libxdamage1" "libxext6" "libxfixes3" "libxrandr2" "libxshmfence1"
echo "Checking firefox..."
_search "ffmpeg" "libatk1.0-0" "libcairo-gobject2" "libcairo2" "libdbus-1-3" "libdbus-glib-1-2" "libfontconfig1" "libfreetype6" "libgdk-pixbuf2.0-0" "libglib2.0-0" "libgtk-3-0" "libpango-1.0-0" "libpangocairo-1.0-0" "libpangoft2-1.0-0" "libx11-6" "libx11-xcb1" "libxcb-shm0" "libxcb1" "libxcomposite1" "libxcursor1" "libxdamage1" "libxext6" "libxfixes3" "libxi6" "libxrender1" "libxt6" "libxtst6"

echo "24.04"
echo "Checking tools..."
_search "xvfb" "fonts-noto-color-emoji" "fonts-unifont" "libfontconfig1" "libfreetype6" "xfonts-cyrillic" "xfonts-scalable" "fonts-liberation" "fonts-ipafont-gothic" "fonts-wqy-zenhei" "fonts-tlwg-loma-otf" "fonts-freefont-ttf"
echo "Checking chromium..."
_search "libasound2t64" "libatk-bridge2.0-0t64" "libatk1.0-0t64" "libatspi2.0-0t64" "libcairo2" "libcups2t64" "libdbus-1-3" "libdrm2" "libgbm1" "libglib2.0-0t64" "libnspr4" "libnss3" "libpango-1.0-0" "libx11-6" "libxcb1" "libxcomposite1" "libxdamage1" "libxext6" "libxfixes3" "libxkbcommon0" "libxrandr2"
echo "Checking firefox..."
_search "libasound2t64" "libatk1.0-0t64" "libcairo-gobject2" "libcairo2" "libdbus-1-3" "libfontconfig1" "libfreetype6" "libgdk-pixbuf-2.0-0" "libglib2.0-0t64" "libgtk-3-0t64" "libpango-1.0-0" "libpangocairo-1.0-0" "libx11-6" "libx11-xcb1" "libxcb-shm0" "libxcb1" "libxcomposite1" "libxcursor1" "libxdamage1" "libxext6" "libxfixes3" "libxi6" "libxrandr2" "libxrender1"

And the result:

20.04
Checking tools...
E: Package 'ttf-unifont' has no installation candidate
E: Package 'ttf-ubuntu-font-family' has no installation candidate
Checking chromium...
E: Package 'libasound2' has no installation candidate
Checking firefox...
24.04
Checking tools...
Checking chromium...
Checking firefox...

I got the list of deps from packages/playwright-core/src/server/registry/nativeDeps.ts

Example

Set an optional platform string when installing, like --with-deps ubuntu24.04, --with-deps 'ubuntu24.04-arm64', or --with-deps=debian12

Or provide a --platform option

Motivation

When you run playwright install it prints out:

BEWARE: your OS is not officially supported by Playwright; downloading fallback build for ubuntu20.04-x64.

My OS is based on 24.04 and, as expected, the fallback fails miserably:

Note, selecting 'libatk-bridge2.0-0t64' instead of 'libatk-bridge2.0-0'
Note, selecting 'libatk1.0-0t64' instead of 'libatk1.0-0'
Note, selecting 'libatspi2.0-0t64' instead of 'libatspi2.0-0'
Note, selecting 'libcups2t64' instead of 'libcups2'
Note, selecting 'libglib2.0-0t64' instead of 'libglib2.0-0'
Note, selecting 'libgtk-3-0t64' instead of 'libgtk-3-0'
Note, selecting 'libxt6t64' instead of 'libxt6'
Note, selecting 'libpng16-16t64' instead of 'libpng16-16'
Note, selecting 'libevent-2.1-7t64' instead of 'libevent-2.1-7'
Note, selecting 'libfontconfig1' instead of 'libfontconfig'
Package ttf-ubuntu-font-family is not available, but is referred to by another package.
This may mean that the package is missing, has been obsoleted, or
is only available from another source

Package libasound2 is a virtual package provided by:
  liboss4-salsa-asound2 4.2-build2020-1ubuntu3
  libasound2t64 1.2.11-1build2 (= 1.2.11-1build2)
You should explicitly select one to install.

Package ttf-unifont is not available, but is referred to by another package.
This may mean that the package is missing, has been obsoleted, or
is only available from another source
However the following packages replace it:
  fonts-unifont

E: Package 'libasound2' has no installation candidate
E: Unable to locate package libx264-155
E: Unable to locate package libenchant1c2a
E: Unable to locate package libicu66
E: Unable to locate package libvpx6
E: Unable to locate package libwebp6
E: Package 'ttf-unifont' has no installation candidate
E: Package 'ttf-ubuntu-font-family' has no installation candidate
Failed to install browsers
Error: Installation process exited with code: 100

I know we're devs and we can't be trusted, but at least it'd be usable 🥴

@GammaGames
Copy link
Author

GammaGames commented Jan 8, 2025

If you found this issue and just want to install the packages, add this function to the script:

function _install() {
    apt-get install -y $@
}

Then change the line to use _install instead of _search and run the script with sudo. The playwright install --force command will still print out some warnings, but the commands I needed appear to work fine

Playwright Host validation warning: 
╔══════════════════════════════════════════════════════╗
║ Host system is missing dependencies to run browsers. ║
║ Missing libraries:                                   ║
║     libicudata.so.66                                 ║
║     libicui18n.so.66                                 ║
║     libicuuc.so.66                                   ║
║     libwebp.so.6                                     ║
║     libffi.so.7                                      ║
╚══════════════════════════════════════════════════════╝

@Skn0tt
Copy link
Member

Skn0tt commented Jan 9, 2025

Try setting the platform with the PLAYWRIGHT_HOST_PLATFORM_OVERRIDE environment variable. Does that help your usecase?

@GammaGames
Copy link
Author

It does! 🙌 Zero results on google when I quote search that text, so thanks for finding that

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

No branches or pull requests

2 participants