build(tools): install playwright deps only when that needs no prompt (#39905)

On Debian/Ubuntu outside GitHub Actions, `tools/playwright.sh` always
ran `pnpm exec playwright install --with-deps`. Installing system
packages needs root: when it isn't root, Playwright tries `sudo` and
falls back to `su`, so a non-root user without passwordless sudo sees
`make playwright` — and the targets depending on it, `make test-e2e` and
`make test-frontend` — either stop and ask for the root password
mid-build or fail outright with `su: System error`.

Related: #38860, which added this script.
---------

Co-authored-by: silverwind <me@silverwind.io>
This commit is contained in:
Chris Eastwoodandsilverwind authored and GitHub committed 2026-10-22 19:59:11 +00:00
1 parent 3a70b85220
commit 4bbe1b918a
1 file changed
+6 -1
+6 -1
View File
@@ -3,7 +3,12 @@ set -euo pipefail
# playwright only supports ubuntu/debian officially, and on CI VMs its system deps are pre-installed
if [ -z "${GITHUB_ACTIONS:-}" ] && [ "$(uname -s)" = "Linux" ] && grep -qE '^ID(_LIKE)?=.*(ubuntu|debian)' /etc/os-release 2>/dev/null; then
pnpm exec playwright install --with-deps "$@"
if [ "$(id -u)" = 0 ] || { command -v sudo >/dev/null 2>&1 && sudo -n true >/dev/null 2>&1; }; then # Avoid Playwright's interactive su fallback.
pnpm exec playwright install --with-deps "$@"
else
pnpm exec playwright install "$@"
echo "Skipped playwright system dependencies (not root and no passwordless sudo), install them with: pnpm exec playwright install-deps" >&2
fi
else
pnpm exec playwright install "$@"
fi