elixir-pdf-generator icon indicating copy to clipboard operation
elixir-pdf-generator copied to clipboard

Application pdf_generator exited: PdfGenerator.start(:normal, []) returned an error: shutdown: failed to start child: PdfGenerator.PathAgent

Open ruben44bac opened this issue 4 years ago • 2 comments

Hi. I have this problem when deploy my elixir project with docker, when I'm working in localhost I don't have problems, I'm using wkhtmltopdf and {:pdf_generator, ">=0.5.7"} this is the error

22:47:37.725 [info] [alarm_handler: {:set, {:system_memory_high_watermark, []}}]
22:47:37.730 [info] Application pdf_generator exited: PdfGenerator.start(:normal, []) returned an error: shutdown: failed to start child: PdfGenerator.PathAgent
    ** (EXIT) an exception was raised:
        ** (RuntimeError) wkhtmltopdf executable was not found on your system
            (pdf_generator) lib/pdf_generator_path_agent.ex:76: PdfGenerator.PathAgent.maybe_raise/3
            (pdf_generator) lib/pdf_generator_path_agent.ex:69: PdfGenerator.PathAgent.raise_or_continue/1
            (pdf_generator) lib/pdf_generator_path_agent.ex:37: PdfGenerator.PathAgent.init_opts/1
            (elixir) lib/agent/server.ex:8: Agent.Server.init/1
            (stdlib) gen_server.erl:374: :gen_server.init_it/2
            (stdlib) gen_server.erl:342: :gen_server.init_it/6
            (stdlib) proc_lib.erl:249: :proc_lib.init_p_do_apply/3
22:47:37.731 [info] [alarm_handler: {:clear, :system_memory_high_watermark}]

this is my dockerfile:

FROM elixir:1.9.1 as builder

ENV MIX_ENV=prod

RUN apt install curl \
  && curl -sL https://deb.nodesource.com/setup_12.x | bash - \
  && apt-get install -y nodejs \
  && apt-get install -y npm

RUN apt-get update && \
    apt-get install -y --no-install-recommends wkhtmltopdf && \
    rm -rf /var/lib/apt/lists/*

RUN mix local.hex --force \
  && mix local.rebar --force
...

help!

ruben44bac avatar Jun 10 '20 22:06 ruben44bac

Hi @ruben44bac ,

First of all, thanks for reporting! Looks like the executable cannot be found on path. You can either configure that path manually (see README) or ... lemme try to reproduce the error.

But before I can take a deeper look into this, I would really recommend to set the path to the wkhtmltopdf executable in the config. This should work. Please let me know if you run into further issues

gutschilla avatar Jun 10 '20 23:06 gutschilla

Thank you! Now I only have this problem, do you know why?

{:error,
 {:generator_failed,
  "/usr/local/bin/wkhtmltopdf: error while loading shared libraries: libXrender.so.1: cannot open shared object file: No such file or directory\n"}}

ruben44bac avatar Jun 11 '20 01:06 ruben44bac