YusukeIwaki/puppeteer-ruby

Support other browser paths

Closed this issue · 3 comments

hmdne commented

Simple description about the feature

Puppeteer-Ruby assumes that Chromium on Linux is located in /opt/google/chrome/chrome which may be an incorrect assumption on some installations.

Below are examples of source of other projects that do support various other paths that work most of the time:

https://github.com/rubycdp/ferrum/blob/master/lib/ferrum/browser/options/chrome.rb#L45-L54
https://github.com/rubycdp/ferrum/blob/master/lib/ferrum/browser/options/firefox.rb#L11-L18
https://github.com/opal/opal/blob/master/lib/opal/cli_runners/chrome.rb#L153-L169

Usecase / Motivation

I am working on a patchset to migrate Opal from the current raw CDP interface to use puppeteer-ruby. We intend for it to work just simply with opal -Rchrome -e 'p 123' with the least user interaction needed on most platforms.

Hi, thank you for the detailed proposal.

We can actually use executable_path parameter for Puppeteer.launch for using the customized path of the browser,
and do you intend to request the improvement of the default path of the browser?
Please let me know the desired behavior with some sample codes if possible. Thank you :)

By the way, the default browser paths are derived from Playwright.
https://github.com/microsoft/playwright/blob/82002b28030ed9d8b5bd2abcc2f79631d932b9ec/packages/playwright-core/src/utils/registry.ts#L326
And I migrated this into Puppeteer(JS) and puppeteer-ruby.

hmdne commented

Yes, I wish that it would be able to better deduce the path, on Linux/Unix at least, distros put Chrome/Chromium in various places, and maybe it's better to assume that $PATH is set correctly than to hardcode a path (because they may be in /opt/google/chrome, /usr/bin, /usr/local/bin, /home/user/bin, /app/bin, but even something like /nix/c78c213089c03471c098712397/bin). The names for stable Chrome/Chromium are the following:

  • google-chrome-stable
  • google-chrome
  • chrome
  • chromium-freeworld
  • chromium-browser
  • chromium

Ferrum has this logic: https://github.com/rubycdp/ferrum/blob/master/lib/ferrum/browser/options/base.rb#L26-L36

Opal has this: https://github.com/opal/opal/blob/master/lib/opal/cli_runners/chrome.rb#L164-L172 (I think it's kind of worse than Ferrum's)

I could of course do the deducing in my codebase, but then that's kind of like code duplication I think and this issue will probably come back in the future when some Linux user will try to use your library... And it may sound like a good idea to separate Chromium to a separate channel but most of the time distributions just repackage the stable Chrome as Chromium.

I also have some more suggestions if you would be interested. I would rather send a pull request, but my time currently is tight :/

@hmdne I tried an implementation for the request. Could you help review it?