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

ExecutablePath option ignored #6614

Closed
nc opened this issue Nov 22, 2020 · 8 comments
Closed

ExecutablePath option ignored #6614

nc opened this issue Nov 22, 2020 · 8 comments

Comments

@nc
Copy link

nc commented Nov 22, 2020

MacOS / BigSur
Node 16 (Head)
puppeteer-core, 5.5.0

const puppeteer = require('puppeteer-core');
const browser = await puppeteer.launch({
  product: 'chrome',
  headless: false,
  executablePath: '/Applications/Google Chrome.app/Contents/MacOS/Google Chrome'
});

Fails with

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

As I understand it, it should not be trying to launch chromium at all given the above options and use of puppeteer-core.

@nc
Copy link
Author

nc commented Nov 22, 2020

If however, one modifies the BrowserRunner directly to hardcode the executablePath as shown above, all works as expected. So it seems to be an issue with how the option is being passed to Puppeteer, or how it's being handled.

class BrowserRunner {
    constructor(executablePath, processArguments, tempDirectory) {
        this.proc = null;
        this.connection = null;
        this._closed = true;
        this._listeners = [];
        this._executablePath = executablePath;
        this._processArguments = processArguments;
        this._tempDirectory = tempDirectory;
    }
    start(options) {
        console.log('>>>>', this._executablePath);
        this._executablePath = '/Applications/Google Chrome.app/Contents/MacOS/Google Chrome';

This prints
>>>> /usr/bin/chromium-browser
and then proceeds to launch Google Chrome as expected.

@eugene1g
Copy link

eugene1g commented Dec 23, 2020

This happens on Apple Silicon. The path is hardcoded at

let chromeExecutable = executablePath;
if (os.arch() === 'arm64') {
chromeExecutable = '/usr/bin/chromium-browser';
} else if (!executablePath) {
introduced in 354f942

Chromium can run natively on Apple Silicon. Puppeteer does not yet link to that binary, but if the developer uses executablePath to point to another Chrome instance (that might not be compatible with Puppeteer), they already take on those risks and the library should just accept that path.

@eugene1g
Copy link

Related #6641 #6495 #6634

@PrzemekCh
Copy link

If however, one modifies the BrowserRunner directly to hardcode the executablePath as shown above, all works as expected. So it seems to be an issue with how the option is being passed to Puppeteer, or how it's being handled.

class BrowserRunner {
    constructor(executablePath, processArguments, tempDirectory) {
        this.proc = null;
        this.connection = null;
        this._closed = true;
        this._listeners = [];
        this._executablePath = executablePath;
        this._processArguments = processArguments;
        this._tempDirectory = tempDirectory;
    }
    start(options) {
        console.log('>>>>', this._executablePath);
        this._executablePath = '/Applications/Google Chrome.app/Contents/MacOS/Google Chrome';

This prints
>>>> /usr/bin/chromium-browser
and then proceeds to launch Google Chrome as expected.

You saved my day :)

@thamwangjun
Copy link

I think this is a duplicate of #6634, and this issue has been fixed in this merge request #6495.
In the latest puppeteer version 10.4.0, executablePath is working in my tests.

@stale
Copy link

stale bot commented Jun 23, 2022

We're marking this issue as unconfirmed because it has not had recent activity and we weren't able to confirm it yet. It will be closed if no further activity occurs within the next 30 days.

@stale stale bot added the unconfirmed label Jun 23, 2022
@stale
Copy link

stale bot commented Jul 23, 2022

We are closing this issue. If the issue still persists in the latest version of Puppeteer, please reopen the issue and update the description. We will try our best to accomodate it!

@stale stale bot closed this as completed Jul 23, 2022
@behemoth-thainv
Copy link

I'm using puppeteer-core@^5.2.1.
Here is solution if you won't update version:

Get chronium path on your device:

which chromium
Screenshot 2023-10-03 at 15 45 11

Modify default executablePath for arm64

path: node_modules/puppeteer-core/lib/cjs/puppeteer/node/Launcher.js
change: '/usr/bin/chromium-browser' -> '/opt/homebrew/bin/chromium'
image

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

No branches or pull requests

5 participants