[BUG] `npx playwright install chrome` command fails in installing
Context:
- Playwright Version: [1.16.2]
- Operating System: [mcr.microsoft.com/playwright:v1.16.2-focal]
- Node.js version: [14]
- Browser: [e.g. All, Chromium, Firefox, WebKit]
- Extra: [we use @playwright/[email protected]]
Our docker image is based on mcr.microsoft.com/playwright:v1.16.2-focal. Our test suite runs in chrome, we'll need to install chrome browser in the container via
RUN npx playwright install chrome
This command stops working since 1.16, it throws out following error in building image
#23 10.62
#23 10.62 2021-10-28 18:13:51 (9.65 MB/s) - 'google-chrome-stable_current_amd64.deb' saved [89046612/89046612]
#23 10.62
#23 10.62 + sudo apt-get install -y ./google-chrome-stable_current_amd64.deb
#23 10.63 sudo: a terminal is required to read the password; either use the -S option to read from standard input or configure an askpass helper
#23 10.63 Failed to install browsers
#23 10.63 Error: Failed to install chrome
RUN npx playwright install chrome
@archlichking Any chance that you've been running this under ROOT user before, and now run it under PWUSER? We don't have passwordless-sudo in our container, so to install chrome you'd need to run under ROOT:
USER root
RUN npx playwright install chrome
@aslushnikov We don't switch user while building the image, the only thing we did after bumping to 1.16.2 was to switch the base image from mcr.microsoft.com/playwright:v1.15.2-focal to mcr.microsoft.com/playwright:v1.16.2-focal. With 1.15.2-focal
This dockerfile can be used to reproduce. If we switch base image back to v1.15.2-focal it works well.
FROM mcr.microsoft.com/playwright:v1.16.2-focal
ENV HOME=/home/pwuser
WORKDIR ${HOME}
# manually install wget due to https://github.com/microsoft/playwright/issues/7785
# according to https://playwright.dev/docs/ci#travis-ci
RUN apt-get install -y wget sudo dumb-init && \
sudo apt-get update --fix-missing
RUN npm install @playwright/test && npx playwright install chrome
ENV HOME=/root
# CMD npx playwright test --config=./playwright.docker.config.ts
ENTRYPOINT ["/usr/bin/dumb-init", "--"]
@archlichking Turns out that's due to us updating NPM from 6 to 7.
The user, group, uid, gid, and unsafe-perms configurations are no longer relevant. When npm is run as root, scripts are always run with the effective uid and gid of the working directory owner.
This has been reported to NPM as well but turned out to be an "intended change": https://github.com/npm/cli/issues/3110
To workaround this, you should run npm commands from a root-owned directory. So something like this:
RUN mkdir /tmp/pwt && cd /tmp/pwt && npm install @playwright/test && npx playwright install chrome
There are a few ways we can workaround this on our end:
- make
pwuseruser inside docker container to have passwordless sudo (tracking bug) - include
chrome-stableby default to our docker container so that you don't have to install it (tracking bug)
We're unlikely to land any of these mitigations as a cherry-pick to 1.16 - we'll need to gather feedback first.
Sorry for the inconvenience!
@archlichking some of the mitigations might be implemented in future, but no ETA.
For this particular issue, the suggested workaround should work, and there's nothing nice we can do on our side – so closing this bug.
If something's still broken, please reach out (via a new issue) - we'll be happy to take a look!