lorca icon indicating copy to clipboard operation
lorca copied to clipboard

Download Chromium if not already installed

Open zserge opened this issue 5 years ago • 5 comments

Although in most cases Chrome/Chromium is already present, it might make sense to download the executable if it can not be found (for better user experience). Somehow https://github.com/puppeteer/puppeteer is able to do that (downloading portable chromium - https://github.com/puppeteer/puppeteer/blob/master/lib/BrowserFetcher.js). This would also fix #12

If there are any volunteers to implement this - I'd be happy to merge the PR ;)

zserge avatar Mar 08 '20 10:03 zserge

Perhaps it seems a little strange, but to solve this I actually use zserge/webview and I ask it to open the url https://www.google.com/chrome/ .

felipetesc avatar Mar 16 '20 23:03 felipetesc

In case anyone else gets ambitious, Puppeteer's files of interest:

  1. install.js
  2. BrowserFetcher.ts
  3. BrowserFetcher.js (might be mostly for experimental feature of getting Firefox)

One interesting question is how to deal with which version of Chromium should be installed? Puppeteer uses whatever's defined in package.json or whatever npm configuration is already given. I'm not sure if it makes the most sense to just get the latest version or if there should be a constant somewhere in lorca that defines what version of Chromium is currently supported (then manually incremented).

amunchet avatar May 29 '20 04:05 amunchet

I could try, but please give a more sensible error message first,

	log.Println("trying to launch")
	w, err := lorca.New("", "", width, height)
	if err != nil {
		log.Fatal(err)
	}
2020/08/31 14:46:34 trying to launch
2020/08/31 14:46:34 fork/exec : no such file or directory
exit status 1

BTW, I use Brave Browser (which there seems to be another issue here.)

patarapolw avatar Aug 31 '20 07:08 patarapolw

I've been using Rod recently for browser automation which has this ability. His launcher library, which is the one downloading the browser, can be used as its own package.

https://github.com/go-rod/rod/tree/master/lib/launcher

mikkel1156 avatar Jul 18 '21 17:07 mikkel1156

By the way, I know this issue is quite old - but that error message comes from the executable not being found or incorrect permissions. Makes sense if you're using Brave - different executable path.

I could try, but please give a more sensible error message first,

	log.Println("trying to launch")
	w, err := lorca.New("", "", width, height)
	if err != nil {
		log.Fatal(err)
	}
2020/08/31 14:46:34 trying to launch
2020/08/31 14:46:34 fork/exec : no such file or directory
exit status 1

BTW, I use Brave Browser (which there seems to be another issue here.)

amunchet avatar Jul 18 '21 19:07 amunchet