pallymore / wkhtmltopdf-binary-edge

this is forked from tolgap/wkhtmltopdf-binary .
MIT License
74 stars 33 forks source link

Support for Alpine Linux OR better error handling! #17

Closed khalilgharbaoui closed 5 years ago

khalilgharbaoui commented 5 years ago

When on Alpine Linux the following error accures:

Traceback (most recent call last):
    1: from ./wkhtmltopdf:15:in `<main>'
./wkhtmltopdf:15:in `exec': No such file or directory - /usr/local/bundle/gems/wkhtmltopdf-binary-edge-0.12.5.0/libexec/wkhtmltopdf-linux-amd64 (Errno::ENOENT)

The included binary is there but it's not compatible with alpine linux.

I see in bin/wkhtmltopdf that the case statement will match RUBY_PLATFORM with: /64.*linux/

In this case, alpine linux version has: x86_64-linux-musl its platform which will match up with the regex But fail without any specific error about the platform not being the right one!

This is confusing and hard to debug.

I noticed you said: This repo is meant for common development uses (e.g. mac, ubuntu) - if I include a binary for every system then gem would be massive... (https://github.com/pallymore/wkhtmltopdf-binary-edge/issues/12#issuecomment-399633610)

It's understandable but then again Alpine Linux is a very common development use case these days. I think a lot of ppl depending on this gem would appreciate the support for it, especially when trying to use lightweight docker images.

I'll see if I can make a fork and PR for it.

Maybe at least wrapping the binary execution call in a rescue block wouldn't hurt?

# bin/wkhtmltopdf
. . .
begin
  exec "#{cmd} #{args.join(' ')}"
rescue Errno::ENOENT => e  
  raise "Not found or wkhtmltopdf binaries might be incompatible with the os version \n #{e}"
end
khalilgharbaoui commented 5 years ago

I decided to create my own fork/version and gem that is also compatible with Alpine Linux 3.9+

https://github.com/khalilgharbaoui/wkhtmltopdf-binary-edge-alpine

I added a link back to this repo in the readme and in the credits section.

would be great if there was a link pointing to that repo from yours for Alpine Linux users?

Cheers

pallymore commented 5 years ago

Hi @khalilgharbaoui - sorry I've been doing away from the gem approach for awhile now. Our apps are all running in containers with wkthmltopdf installed as binaries instead of provided via gems.

I will add your fork in the README file. Thanks!