1

i want to use wkhtmltopdf in my php application. therefor i added wkhtmltopdf to my apt.yml file and hoped that everything will work...

...unfortunately, it doesn't.

everytime i run wkhtmltopdf google.ch output.pdf i get the following error:

wkhtmltopdf: error while loading shared libraries: libGL.so.1: cannot open shared object file: No such file or directory

does anybody know how to setup wkthtmltopdf correct in the php-builtpack of cloud foundry?

Nio
  • 497
  • 3
  • 6
  • 16
  • 1
    For now I use the static builded https://github.com/h4cc/wkhtmltopdf-amd64 composer dependency... – Nio Oct 23 '18 at 12:32

1 Answers1

1

Two possibilities:

  • You are missing shared libraries dependencies. You'll need to add those to apt.yml so they get installed as well. It looks like libgl1-mesa-dev might be what you're missing. There could be others though. If you run ldd wkthtmltopdf, you can see a list of all the dependencies & what's missing.

  • The dependencies are installed, but they're not found when you try to run wkthtmltopdf. If you're running cf ssh to go into an app container so you can run wkthtmltopdf this might be the issue. Try running cf ssh "<app-name>" -t -c "/tmp/lifecycle/launcher /home/vcap/app bash ''" instead. Otherwise, you need to manually source the .profile.d/* scripts. Buildpacks set env variables in these scripts and they often indicate where shared libraries can be loaded.

Hope that helps!

Daniel Mikusa
  • 13,716
  • 1
  • 22
  • 28
  • 1
    yes, we already use the `cf ssh "" -t -c "/tmp/lifecycle/launcher /home/vcap/app bash ''"` command to open the ssh connection. I have added `libgl1-mesa-dev` to my `apt.yml` and can see it gets installed during `cf push` but the error of wkhtmltopdf still presists... When I run `ldd /home/vcap/deps/0/bin/wkhtmltopdf` only `libgl.so.1` is not found. Do you have another idea how to install the missing lib? – Nio Oct 23 '18 at 06:16
  • 1
    If you know `libgl.so.1` is installed but `ldd` is not seeing it, then there's probably an issue with the `LD_LIBRARY_PATH`. You might need to adjust that. Your solution is probably better though, there's a static binary available so just use that. – Daniel Mikusa Oct 23 '18 at 18:30