Closed puneetpandey closed 3 years ago
I have recently upgraded my Rails application from 6.0 to 6.1
Did you also change your linux container or upgrade something else besides Rails? I would expect the libpng thing to only show up if dealing with a new linux system or a new wkhtmltopdf
version.
Have you tried installing wkhtmltopdf
as a system package, and using that binary (if available)?
You may also want to try installing gem 'wkhtmltopdf-binary', git: 'https://github.com/zakird/wkhtmltopdf-binary', branch: 'master'
, as I think there may be some fixes related Amazon linux 1 vs 2 that haven't been released yet.
If any of this helps, please let me know.
@unixmonkey not changed and updated linux container, though some of the gems also got upgraded because of Rails upgrade but I think that has not affected wickedpdf gem and wkhtmltopdf gem
I am going to try the alternate approach (to install gem from git) shortly and update here.
Tried using the gem from git directly: gem 'wkhtmltopdf-binary', github: 'zakird/wkhtmltopdf_binary_gem', branch: 'master'
and set the permission as well but getting the same error.
Though I have noticed that after I ran bundle update
and not bundle update rails
, wicked_pdf
and wkhtmltopdf-binary
got upgraded as well.
here's the snapshot:
- wicked_pdf (2.0.1)
+ wicked_pdf (2.1.0)
activesupport
- wkhtmltopdf-binary (0.12.5.4)
+ wkhtmltopdf-binary (0.12.6.5)
So I think when you said, libpng.so to show up when dealing with new wkhtmltopdf
version seems true in this case. I am now trying switching to last compatible version for this. Meanwhile do you any have pointers for me to try?
P.S. Thanks for your prompt reply.
@unixmonkey here's what worked for me:
Gemfile
gem 'wicked_pdf', '~> 2.0', '>= 2.0.1'
gem 'wkhtmltopdf-binary', '0.12.6'
Gemfile.lock
wicked_pdf (2.1.0)
activesupport
wkhtmltopdf-binary (0.12.6)
wicked_pdf (~> 2.0, >= 2.0.1)
wkhtmltopdf-binary (= 0.12.6)
.ebextensions/commands.config
03_set_wkhtmltopdf_binary_permissions:
command: "chmod -R 777 /opt/rubies/ruby-2.6.6/lib/ruby/gems/2.6.0/gems/wkhtmltopdf-binary-0.12.6/bin/"
I should have looked at this versioning mismatch thing earlier. Many thanks to you.
Hi,
I have recently upgraded my Rails application from 6.0 to 6.1 and after upgrading whenever I am trying to generate a PDF, I get this error:
RuntimeError: Failed to execute: ["/opt/rubies/ruby-2.6.6/bin/wkhtmltopdf", "--orientation", "Landscape", "--margin-top", "25", "--margin-bottom", "10", "--header-spacing", "3", "--header-html", "file:////tmp/wicked_header_pdf20210506-22237-1tx5wdw.html", "--footer-html", "file:////tmp/wicked_footer_pdf20210506-22237-1fo4wp6.html", "file:////tmp/wicked_pdf20210506-22237-1c7ctor.html", "/tmp/wicked_pdf_generated_file20210506-22237-1c2hpwj.pdf"] Error: PDF could not be generated! Command Error: /opt/rubies/ruby-2.6.6/lib/ruby/gems/2.6.0/gems/wkhtmltopdf-binary-0.12.6.5/bin/wkhtmltopdf_centos_7_amd64: error while loading shared libraries: libpng15.so.15: cannot open shared object file: No such file or directory
I tried following the steps by following this link: https://majestic.cloud/how-to-install-wkhtmltopdf-on-amazon-linux/ to install libpng manually but problem remains as-is
# wkhtmltopdf https://majestic.cloud majestic.pdf /opt/rubies/ruby-2.6.6/lib/ruby/gems/2.6.0/gems/wkhtmltopdf-binary-0.12.6.5/bin/wkhtmltopdf_centos_7_amd64: error while loading shared libraries: libpng15.so.15: cannot open shared object file: No such file or directory
Here's what my Gemfile looks like:
Here's my
config/initializers/wicked_pdf.rb
And since the app is hosted on ElasticBeanstalk the permission has been set via ebextensions