puppeteer: The chromium binary is not available for arm64
Bug description
In an ARM based Docker container (or ARM based Linux):
npm install puppeteer
Error:
The chromium binary is not available for arm64.
This is related to #6622 which wasn’t really solved just worked around via Rosetta.
I’m trying to build an ARM based Docker Image that uses BackstopJS/puppeteer. Ref https://github.com/garris/BackstopJS/issues/1300
Are there any plans to build an arm64 version of chromium
?
Puppeteer version
10.0.0
Node.js version
16.3.0
npm version
7.15.1
What operating system are you seeing the problem on?
Linux
Relevant log output
No response
About this issue
- Original URL
- State: open
- Created 3 years ago
- Reactions: 110
- Comments: 58 (5 by maintainers)
Commits related to this issue
- Use Chromium provided by Debian maintainers to pass arm64 builds https://github.com/puppeteer/puppeteer/issues/7740 — committed to it-novum/puppeteer-docker by nook24 2 years ago
- chore: create `Dockerfile` and nginx config file https://github.com/puppeteer/puppeteer/issues/7740#issuecomment-1162729846 https://github.com/it-novum/puppeteer-docker/blob/development/Dockerfile ht... — committed to ngseke/ngseke.me-archive by ngseke 2 years ago
- chore: create `Dockerfile` and nginx config file https://github.com/puppeteer/puppeteer/issues/7740#issuecomment-1162729846 https://github.com/it-novum/puppeteer-docker/blob/development/Dockerfile ht... — committed to ngseke/ngseke.me-archive by ngseke 2 years ago
- chore: create `Dockerfile` and nginx config file https://github.com/puppeteer/puppeteer/issues/7740#issuecomment-1162729846 https://github.com/it-novum/puppeteer-docker/blob/development/Dockerfile ht... — committed to ngseke/ngseke.me-archive by ngseke 2 years ago
- Pin chromium install https://github.com/puppeteer/puppeteer/issues/7740#issuecomment-970490323 — committed to wmo-im/wis2box-ui by webb-ben 2 years ago
- Pin chromium install (#65) * Pin chromium install https://github.com/puppeteer/puppeteer/issues/7740#issuecomment-970490323 * Undo changes to ghcr.yml — committed to wmo-im/wis2box-ui by webb-ben 2 years ago
- Support live server tests with Selenium and add first test diff --git a/deployment/provision_vagrant_vm.sh b/deployment/provision_vagrant_vm.sh index 6c1c539f..5d478d2a 100755 --- a/deployment/provis... — committed to hansegucker/EvaP by hansegucker 7 months ago
- Drop puppeteer test environment diff --git a/.github/dependabot.yml b/.github/dependabot.yml index 9b48bb90..3e6ade14 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -18,7 +18,5 @... — committed to hansegucker/EvaP by hansegucker 3 months ago
- Support live server tests with Selenium and add first test diff --git a/deployment/provision_vagrant_vm.sh b/deployment/provision_vagrant_vm.sh index 6c1c539f..5d478d2a 100755 --- a/deployment/provis... — committed to hansegucker/EvaP by hansegucker 7 months ago
- Drop puppeteer test environment diff --git a/.github/dependabot.yml b/.github/dependabot.yml index 9b48bb90..3e6ade14 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -18,7 +18,5 @... — committed to hansegucker/EvaP by hansegucker 3 months ago
I have arm64 Chromium binaries available at www.chromiumforlambda.com
Thanks @talisto, that’s what I’ve been doing as a work around, but took two days to come up with that. https://github.com/garris/BackstopJS/issues/1300#issuecomment-958561525
I’m using puppeteer via Backstop JS and in my scenario Backstop uses a Docker image to do the screenshot comparisons (yields consistent results across OSes)
It would be nice if
npm install puppeteer
worked for multi-platform Docker images instead of trying to figure out how to add chromium yourself.A workaround I’m using is to install chromium with the base image’s package manager (e.g.
apk add chromium
if you’re using the node alpine image), and then useENV PUPPETEER_SKIP_CHROMIUM_DOWNLOAD true
in the Dockerfile beforenpm install puppeteer
to tell puppeteer to skip installing chromium. You may have to change the puppeteer executable path to use the package manager’s version of chromium.This is what I’m currently using:
…some of which I lifted from here: https://github.com/ebidel/try-puppeteer/blob/master/backend/Dockerfile
…which is mostly based on the “Running Puppeteer in Docker” section of the Puppeteer troubleshooting docs: https://github.com/puppeteer/puppeteer/blob/main/docs/troubleshooting.md#running-puppeteer-in-docker
The only relevant bits to this issue are the
ENV
statements, and addingchromium
to the packages installed by the package manager.This ^
Following the instructions here solved the issue for me: https://broddin.be/2022/09/19/fixing-the-chromium-binary-is-not-available-for-arm64/
Add the following lines to
~/.zshrc
and
I feel compelled to send you a basket of mini muffins. 😄 ❤️
I’ve spent a few hours trying to run one of our Docker containers on Linux/arm64, it was hard and mostly trial and error mode. My final setup is
Debian 11
andChromium 103.0.5060.53 built on Debian 11.3, running on Debian 11.3
, the magic is in the bunch of flags I have had to set to make Puppeteer not stuck on aawait browser.newPage()
, and avoid segment faults and device access errors.the whole PR is at https://github.com/elastic/apm-integration-testing/pull/1493
@ReDrUm you can test my Dockerfile: https://github.com/it-novum/puppeteer-docker/blob/development/Dockerfile I have not tested it on Apple M1, but it is running on Linux arm64.
As @wujekbogdan says, using a package-managed version is unworkable, but a solution, assuming you trust their builds is to use the arm64 chromium provided by Playwright, built/hosted Microsoft.
It’s a little fiddly but the point of their project is to automatically build the latest versions of browsers for all platforms. This means that you can look at the commit history of
browsers.json
to find the build ID you want that aligns with https://pptr.dev/chromium-support and download that build zip.For example, Puppeteer v21.5.0 wants Chromium 119.0.6045.105 and that’s in r1088, which can be downloaded from:
In addition, a
HEAD
request to this URL will yield acontent-md5
header, which can be validated against the downloaded .zip file. This build of Chromium has worked for me on arm64 with both Ubuntu 22.04 and Amazon Linux 2023.Ideally, Puppeteer would work natively with arm64 though 😃 👍
All workarounds posted on this thread are unreliable because they are all based on installing a random version of Chrome via a package manager (no matter if it’s
brew
,apk
, orapt
).The official Puppeteer docs clearly say that:
So while installing a stable Chromium version via a package manager works, it doesn’t guarantee that it works well because there’s no guarantee it was tested with the version of Puppeteer you use.
Also, Linux ARM is becoming more common with public clouds (thinking mainly AWS Graviton here in my experience).
It’s important to note the tight version requirements between Puppeteer and Chromium when using this approach. The version of Chromium currently available in alpine3.15 is 99.0.4844.84-r0, which mean the versions of Puppeteer you could/should use are 13.2.0-13.4.1. However, if you’re using an alpine3.14 image, you’ll get Chromium 93.0.4577.82-r0, which maps to Puppeteer 10.2.0-11.0.0.
All I had to do to get it working on my M1 chip was add:
Then added
executablePath: '/usr/bin/chromium',
when launching puppeteer:Dockerfile for above solution (no md5 checksum):
hello, could you please share your
dockerfile
, thank you!@20manas solution does work.
however if you want to abstract the hardcoded url away and have an architecture-independent Dockerfile then you can just
npm install playwright@^1.42.1
and thennpx playwright install chromium —with-deps
. This does the same download but without hardcoding the urlYep, I wanted to fix a last minute bug 😃 Done --> https://github.com/juananpe/puppeteer-in-docker-in-m1
If you run Puppeteer on Apple Silicon in Docker, you need the Linux ARM version.
Would love to see it added.
That’s pretty annoying. Thanks for sharing @flaushi looks like I have to go to the same rabbit hole like you. I’m not sure about how to map the versions together. From the current docs it says:
But the
revisions.ts
ofv13.5.0
claims: https://github.com/puppeteer/puppeteer/blob/7b38b458c91f4180a29cee10698a909bea911f67/src/revisions.ts#L22-L25confusing
Step 2: Allow Chromium to open on your M1 Mac:
The ARM binary is available with the env var
PUPPETEER_EXPERIMENTAL_CHROMIUM_MAC_ARM
. We are going to fully support it once GitHub Actions offer Mac ARM devices.P.S. the env var downloads the build for Mac ARM though but afaik there are not chromium builds published for Linux ARM. P.P.S. https://commondatastorage.googleapis.com/chromium-browser-snapshots/index.html
Is anyone else running multi-arch images for visual-regression testing and noticing discrepancies between visual snapshots taken on say an amd64 vs arm64 image? For my codebase i’m seeing differences in drop shadows between systems using the same Debian image (albeit it the chromium arch differs)
@ReDrUm the ideal fix would be an arm build of Chromium for Debian, but doesn’t sound like that’s on Puppeteer’s radar.
Here’s the Dockerfile I used to work around my issues (unfortunately it’s an old version of Chrome) https://github.com/garris/BackstopJS/issues/1300#issuecomment-1018707468
@talisto would you mind sharing your
Dockerfile
to help all of this issue’s followers?Node.js version 14.18.1
Npm version 6.14.15
Environment :
Kernel :
Issue :
Based on @nook24 works, I created a docker with dumb-init and wkhtmltopdf which works in both arm64 and amd64 (tested on both on Linux and Mac)
https://github.com/alaminopu/puppeteer-docker
Docker hub: https://hub.docker.com/repository/docker/alaminopu/puppeteer-docker/general
@drmrbrewer see https://storage.googleapis.com/chromium-browser-snapshots/index.html We are happy to review a PR implementing an alternative way to download chromium binaries. For now, you can use the package manager builds (just make sure they are compatible).
@MarcusOtter the problem is that Chromium binaries are not available for linux arm64
Have you considered something like BuildJet for GitHub Actions? It supports ARM and is supposed to be faster & cheaper: https://buildjet.com/for-github-actions
PS: The issue for GitHub Actions adding ARM support is: https://github.com/actions/runner-images/issues/5631
108.0.5359.94
should good enough for 19.3.0 (but not for 19.4.0). Normally if it is the same major version, it’s compatible.Beware that the Chromium version installed via apt might not be completely compatible with the puppeteer version: double check the compatibility via https://pptr.dev/chromium-support
@nicostubi My Docker Container is using
node:16-bullseye-slim
as base image with"puppeteer": "^13.7.0",
https://github.com/it-novum/puppeteer-docker/blob/development/src/package.jsonI did not use Alpine as base image because chromium was not working (or in a wrong version or whatever can’t remember) on alpine
https://linguinecode.com/post/how-to-fix-m1-mac-puppeteer-chromium-arm64-bug this helped me
I check the CHANGELOG, which is also published as GitHub release notes. Puppeteer releases that pull in a new Chromium version will include the version and snapshot revision number. For example:
That version applies until the next release that notes a Chromium change.
How do you get the mapping from Chromium 99.0.4844.84-r0 to puppeteer versions 13.2.0-13.4.1? Inspecting
revisions.ts
for 13.4.0, I see here https://github.com/puppeteer/puppeteer/blob/v13.4.0/src/revisions.tsI am trying to solve this for debian bullseye, which would install https://packages.debian.org/de/bullseye/chromium version 99.0.4844.74-1~deb11u1. Seems it’s the same version rquirements but I don’t get the mapping from
961656
to version 99.0.4844.84-r0 …I just noticed that the Puppeteer docs actually have an example for Docker using Alpine which also sets
PUPPETEER_SKIP_CHROMIUM_DOWNLOAD
and uses the package manager to download Chromium:https://github.com/puppeteer/puppeteer/blob/main/docs/troubleshooting.md#running-on-alpine