question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Cannot spawn Chromium with custom executablePath on Apple M1

See original GitHub issue

Steps to reproduce

Tell us about your environment:

  • Puppeteer version: puppeteer-core 5.5.0 (puppeteer could not install due to #6622)
  • Platform / OS version: macOS Big Sur 11.0.1 (on Macbook Air, M1, 2020)
  • URLs (if applicable): No
  • Node.js version: v15.2.1 (arm64 build)

What steps will reproduce the problem?

Please include code that reproduces the issue.

  1. Install puppeteer-core
  2. Make test.js:
const puppeteer = require('puppeteer-core')

;(async () => {
  const browser = await puppeteer.launch({
    executablePath:
      '/Applications/Google Chrome.app/Contents/MacOS/Google Chrome',
  })
  const page = await browser.newPage()
  await page.goto('https://example.com')
  await page.screenshot({ path: 'example.png' })

  await browser.close()
})()
  1. Run node ./test.js

What is the expected result?

Take a screenshot of https://example.com/ into example.png, with using custom executable path.

What happens instead?

Puppeteer tries to spawn not existed chromium path /usr/bin/chromium-browser.

/Users/yhatt/Programs/tmp/node_modules/puppeteer-core/lib/cjs/puppeteer/node/BrowserRunner.js:193
            reject(new Error([
                   ^

Error: Failed to launch the browser process! spawn /usr/bin/chromium-browser ENOENT


TROUBLESHOOTING: https://github.com/puppeteer/puppeteer/blob/main/docs/troubleshooting.md

    at onClose (/Users/yhatt/Programs/tmp/node_modules/puppeteer-core/lib/cjs/puppeteer/node/BrowserRunner.js:193:20)
    at ChildProcess.<anonymous> (/Users/yhatt/Programs/tmp/node_modules/puppeteer-core/lib/cjs/puppeteer/node/BrowserRunner.js:185:85)
    at ChildProcess.emit (node:events:329:20)
    at Process.ChildProcess._handle.onexit (node:internal/child_process:275:12)
    at onErrorNT (node:internal/child_process:467:16)
    at processTicksAndRejections (node:internal/process/task_queues:80:21)

I think Puppeteer is always overriding executable path when running on arm64. (https://github.com/puppeteer/puppeteer/pull/5167)

https://github.com/puppeteer/puppeteer/blob/46e74ff3f549ef9a99a40114a4b6305a0f88ffab/src/node/Launcher.ts#L107-L108

UPDATE: #6495 may fix it.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:8 (2 by maintainers)

github_iconTop GitHub Comments

17reactions
seanayecommented, Jan 6, 2021

@mathiasbynens I’ve confirmed #6495 patch will fix the problem on Apple Silicon. Following is steps how to confirm:

  1. Apply #6495 patch into main branch
  2. Run npm run build
  3. Create a custom Puppeteer package through npm pack
  4. Install created package to the example project via PUPPETEER_SKIP_CHROMIUM_DOWNLOAD=1 npm i puppeteer-5.5.0-post.tgz.
  5. Rewrite require('puppeteer-core') to require('puppeteer') in test.js
  6. Run node ./test.js

Build steps (1-3) may require Intel arch. I used Linux VM provided by GitHub Codespaces to create package.

It can take the screenshot via custom Chrome process even if used Apple SIlicon, like this:

example

For anyone lazy coming from google, or for anyone without access to an x86 machine I have prepackaged this binary for use with a homebrew chromium install

Steps:

  1. brew install chromium
  2. yarn add https://github.com/seanaye/puppeteer/releases/download/v5.5.0-apple-silicon/puppeteer-core-5.5.0-post.tgz
  3. inside your node app
import puppeteer from 'puppeteer-core'

async function main () {
  const browser = await puppeteer.launch({
    executablePath: '/Applications/Chromium.app/Contents/MacOS/Chromium',
    headless: false
  })
  ...
3reactions
yhattcommented, Mar 22, 2021

Confirmed it has been fixed in the latest puppeteer-core v7!

Are you thinking that this problem has not resolved? This issue is focusing to the custom executable path for puppeteer-core (NOT puppeteer), and I’ve definietly confirmed fix in v7.0.0.

If you’re looking for the issue about installation failure of puppeteer on Apple M1, you should track #6622 instead of this issue.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Error: Failed to launch the browser process! spawn /usr/bin ...
Run the above command inside this path to find missing dependencies - /node_modules/puppeteer/.local-chromium/linux-[970485]/chrome-linux.
Read more >
How to fix M1 Mac Puppeteer chromium arm64 bug
Step 1: Install chromium with Homebrew · Step 2: Allow Chromium to open on your M1 Mac · Step 3: Skip future Chromium...
Read more >
How To Load Chrome In Puppeteer On Mac - ADocLib
Install Puppeteer on Windows or Mac OS whichever you prefer. ... Cannot spawn Chromium with custom executablePath on Apple M1 #6634.
Read more >
Right-click on Mac - Apple Support
Control-click: Press and hold the Control key while you click an item. For example, Control-click an icon, a window, the toolbar, the desktop,...
Read more >
puppeteer-core - npm
A high-level API to control headless Chrome over the DevTools Protocol. Latest version: 19.4.1, last published: 9 days ago.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found