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

fix executablePath (arm64) #6495

Merged
merged 6 commits into from Jan 8, 2021
Merged

fix executablePath (arm64) #6495

merged 6 commits into from Jan 8, 2021

Conversation

alex2844
Copy link
Contributor

@alex2844 alex2844 commented Oct 9, 2020

const puppeteer = require('puppeteer-core');
(async () => {
  const browser = await puppeteer.launch({ executablePath: '/usr/bin/chromium' });
  await browser.close();
})();
Error: Failed to launch the browser process! spawn /usr/bin/chromium-browser ENOENT
TROUBLESHOOTING: https://github.com/puppeteer/puppeteer/blob/main/docs/troubleshooting.md

@google-cla
Copy link

google-cla bot commented Oct 9, 2020

Thanks for your pull request. It looks like this may be your first contribution to a Google open source project (if not, look below for help). Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

📝 Please visit https://cla.developers.google.com/ to sign.

Once you've signed (or fixed any issues), please reply here with @googlebot I signed it! and we'll verify it.


What to do if you already signed the CLA

Individual signers
Corporate signers

ℹ️ Googlers: Go here for more info.

@google-cla google-cla bot added the cla: no label Oct 9, 2020
@alex2844
Copy link
Contributor Author

alex2844 commented Oct 9, 2020

@googlebot I signed it!

@google-cla google-cla bot added cla: yes and removed cla: no labels Oct 9, 2020
console.error(`If you are on Ubuntu, you can install with: `);
console.error(`\n apt-get install chromium-browser\n`);
throw new Error();
fs.stat('/usr/bin/chromium', function (err, stats) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(I'm not familiar with arm64) why would it maybe be in chromium-browser or chromium? Should we update the error message too?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jackfranklin The error was updated

@mathiasbynens
Copy link
Member

Suggested commit message:

feat: support fetching and launching on Apple M1

Issue: #6495, #6634, #6641, #6614

@mathiasbynens
Copy link
Member

@alex2844 Could you please run npm run lint and fix the issues? https://travis-ci.com/github/puppeteer/puppeteer/jobs/465377239#L239-L304

Then we can merge this!

@tylersmalley
Copy link

tylersmalley commented Jan 5, 2021

Any way to get movement on this with a release? ❤️

@connorlurring
Copy link

Any way to get movement on this with a release? ❤️

+1 for this, willing to help @alex2844 get this over the line if necessary

tylersmalley pushed a commit to elastic/puppeteer that referenced this pull request Jan 6, 2021
Signed-off-by: Tyler Smalley <tyler.smalley@elastic.co>
@google-cla
Copy link

google-cla bot commented Jan 6, 2021

All (the pull request submitter and all commit authors) CLAs are signed, but one or more commits were authored or co-authored by someone other than the pull request submitter.

We need to confirm that all authors are ok with their commits being contributed to this project. Please have them confirm that by leaving a comment that contains only @googlebot I consent. in this pull request.

Note to project maintainer: There may be cases where the author cannot leave a comment, or the comment is not properly detected as consent. In those cases, you can manually confirm consent of the commit author(s), and set the cla label to yes (if enabled on your project).

ℹ️ Googlers: Go here for more info.

@google-cla google-cla bot added cla: no and removed cla: yes labels Jan 6, 2021
@alex2844
Copy link
Contributor Author

alex2844 commented Jan 6, 2021

@googlebot I consent.

@google-cla
Copy link

google-cla bot commented Jan 6, 2021

All (the pull request submitter and all commit authors) CLAs are signed, but one or more commits were authored or co-authored by someone other than the pull request submitter.

We need to confirm that all authors are ok with their commits being contributed to this project. Please have them confirm that by leaving a comment that contains only @googlebot I consent. in this pull request.

Note to project maintainer: There may be cases where the author cannot leave a comment, or the comment is not properly detected as consent. In those cases, you can manually confirm consent of the commit author(s), and set the cla label to yes (if enabled on your project).

ℹ️ Googlers: Go here for more info.

@mathiasbynens
Copy link
Member

I’ll go ahead and land this, and will fix any remaining lint issues as a follow-up. Thanks, everyone!

@mathiasbynens mathiasbynens merged this pull request into puppeteer:main Jan 8, 2021
controversial added a commit to controversial/resume that referenced this pull request Jan 12, 2021
This will fix Apple M1 machines once puppeteer/puppeteer#6495 lands
@okonet
Copy link

okonet commented Feb 10, 2021

I still have issues installing puppeteer on M1 Mac since it's looking for the the executable to be in /usr/bin/chromium but the the homebrew installation installs packages to /opt/homebrew/bin on Big Sur so it still fails for me. Any suggestions how to resolve it?

@karlhorky
Copy link
Contributor

I added the following to ~/.zshrc as suggested on #6622 (comment)

export PUPPETEER_SKIP_CHROMIUM_DOWNLOAD=true
export PUPPETEER_EXECUTABLE_PATH=`which chromium`

...and then used patch-package to modify the puppeteer package:

diff --git a/node_modules/puppeteer/lib/cjs/puppeteer/node/Launcher.js b/node_modules/puppeteer/lib/cjs/puppeteer/node/Launcher.js
index 835c74c..1d6e940 100644
--- a/node_modules/puppeteer/lib/cjs/puppeteer/node/Launcher.js
+++ b/node_modules/puppeteer/lib/cjs/puppeteer/node/Launcher.js
@@ -72,7 +72,7 @@ class ChromeLauncher {
         let chromeExecutable = executablePath;
         if (!executablePath) {
             if (os.arch() === 'arm64') {
-                chromeExecutable = '/usr/bin/chromium-browser';
+                chromeExecutable = '/opt/homebrew/bin/chromium';
             }
             else {
                 const { missingText, executablePath } = resolveExecutablePath(this);

@phcoliveira
Copy link

Is there a reason for not using an environment variable before the hardcoded path suggested by Homebrew? Chromium can be installed without using Homebrew, can it not?

chromeExecutable = process.env.CHROMIUM_EXECUTABLE_PATH || '/opt/homebrew/bin/chromium';

@karlhorky
Copy link
Contributor

@phcoliveira, to me this looks great! Want to do a PR and see if the maintainers agree?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

8 participants