hrbrmstr / decapitated

Headless 'Chrome' Orchestration in R
Other
65 stars 3 forks source link

On windows, getting chrome version opens browser and does not work. #6

Open cderv opened 5 years ago

cderv commented 5 years ago

I am on windows 10 and decapitated::chrome_version() is not working properly. This affects others functions that calls it, like decapitated::chrome_dump_pdf().

This is a related to a known bug I think https://bugs.chromium.org/p/chromium/issues/detail?id=158372 --version does not work on windows.

Looking at the code, I am not sure to see why the need to get the version. In chrome_dump_pdf for example, vers is not used after being assigned. Should we get rid of chrome_version calls in functions that do not need it ?

If version is needed, it needs a workaround on windows.

To share, in case you don't know, there is another approach with chrome headless in pagedown to propose a function like chrome_dump_pdf

cderv commented 5 years ago

For getting the version on windows, I did not manage to make the workaround proposed in chromium bug report with wmic datafile

However, using powershell it worked.

args <- c(
  "-NoLogo", 
  "-NoProfile",
  "-Command",
  glue::glue("(Get-Item -Path {glue::single_quote(Sys.getenv('HEADLESS_CHROME'))}).VersionInfo.ProductVersion")
)

res <- processx::run("powershell", args)
trimws(res$stdout)
#> [1] "70.0.3508.0"

Is this something that we could do when on windows OS ?

hrbrmstr commented 5 years ago

oh i rly like that approach! do you want me to change the code or would you like to PR?

cderv commented 5 years ago

I could do a PR for chrome_version to this specific case on windows.

About the call to chrome_version, https://github.com/hrbrmstr/decapitated/blob/ccab8fa640b415cf70535013f5bc4280b6af0e11/R/chrome-pdf.r#L72 Object vers does not seem to be used after. am I missing something ?

hrbrmstr commented 5 years ago

I'm not sure why I put that in (I think I had plans to potentially enable functions by new features they might add if folks need to keep using older versions.