Failed to determine Chrome version
Hi, thanks a lot for creating and maintaing this lib.
I have recently faced an error, I am using chromic version{:chromic_pdf, "~> 1.16"} and using a remote chromium to print PDFs
In my runtime.exs for prod I have set
config :my_app, ChromicPDF,
on_demand: false,
chrome_address: {
System.get_env("CHROME_HOST"),
System.get_env("CHROME_PORT", "9222") |> String.to_integer()
},
session_pool: [
# in milliseconds
timeout: 10_000_000,
# number of concurrent sessions
size: 4
]
On my local everything works, I am using local chromium.
Wwhen I try to print PDFs on the server it works fine when using ChromicPDF.print_to_pdf({:url, url}) however when I try to use the ChromicPDF.Template.source_and_options/1 it fails with an error regarding chrome version.
This code
[
content: html,
size: :a4,
header_height: 0.4166666667,
footer_height: 0.3645833333
]
|> ChromicPDF.Template.source_and_options()
|> ChromicPDF.print_to_pdf(output: file_path)
Generates an error like
07:16:07.607 [error] Task #PID<0.4500.0> started from #PID<0.4499.0> terminating
** (RuntimeError) Failed to determine Chrome version.
If you're using a remote chrome instance, please configure ChromicPDF manually:
config :chromic_pdf, chrome_version: "Google Chrome 120.0.6099.71"
Afterwards, force a recompilation with:
mix deps.compile --force chromic_pdf
--- original exception --
** (RuntimeError) could not find executable from ["chromium-browser", "chromium", "google-chrome", "chrome", "chrome.exe", "/usr/bin/chromium-browser", "/usr/bin/chromium", "/usr/bin/google-chrome", "/Applications/Google Chrome.app/Contents/MacOS/Google Chrome", "/Applications/Chromium.app/Contents/MacOS/Chromium"]
(chromic_pdf 1.16.0) lib/chromic_pdf/pdf/chrome_runner.ex:85: ChromicPDF.ChromeRunner.executable/1
Following this issue I tried adding the Chrome version in config.exs
config :my_app, ChromicPDF, chrome_version: "117.0.5938.62"
and redeployed but I faced the same error.
Any help and advice regarding this?
Hi @Pro-Alchemist ,
the chrome_version option is actually a compile-time config, as opposed to the others, which are really init args to the supervision tree. Option is specified like this:
config :chromic_pdf, chrome_version: "117.0.5938.62"
Make sure you recompile chromic_pdf afterwards; e.g. mix deps.compile --force chromic_pdf and purge your build caches if you cache _build on CI.
Sorry for the inconvenience. This compile-time config option isn't really ideal, maybe it would have been nicer to just add a :disable_zoom option to the functions in Template, but TBH I didn't expect so many people to use this "remote chrome" feature at all (and have never done so myself).