Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

wkhtmltopdf Dependency Issue on Heroku-24 Stack #179

Open
CarlosAwo opened this issue Aug 22, 2024 · 3 comments
Open

wkhtmltopdf Dependency Issue on Heroku-24 Stack #179

CarlosAwo opened this issue Aug 22, 2024 · 3 comments

Comments

@CarlosAwo
Copy link

CarlosAwo commented Aug 22, 2024

Issue description

When attempting to generate a PDF using wicked_pdf with wkhtmltopdf on Heroku, the process fails with a 500 Internal Server Error. The logs indicate that the issue is related to the wkhtmltopdf executable failing to load a required shared library (libssl.so.1.1).

The specific error message from the logs is:

RuntimeError (Failed to execute:
["/app/vendor/bundle/ruby/3.2.0/gems/wkhtmltopdf-heroku-2.12.6.0/bin/wkhtmltopdf-linux-amd64", "--orientation", "Landscape", "--header-left", "Rapport", "--header-right", "Report ", "--header-font-size", "8", "--footer-left", "Généré depuis App Name, le 29/07/2024", "--footer-right", "Page [page]/[topage]", "--footer-font-size", "8", "file:////tmp/wicked_pdf20240729-2-op1664.html", "/tmp/wicked_pdf_generated_file20240729-2-ew0j4z.pdf"]
Error: PDF could not be generated!
Command Error: /app/vendor/bundle/ruby/3.2.0/gems/wkhtmltopdf-heroku-2.12.6.0/bin/wkhtmltopdf-linux-amd64: error while loading shared libraries: libssl.so.1.1: cannot open shared object file: No such file or directory

Expected or desired behavior

The PDF should be generated successfully without encountering shared library errors. The expected behavior is for wkhtmltopdf to be able to generate the PDF with the provided parameters and template.

System specifications
wicked_pdf gem version:
wicked_pdf (2.6.3)
wicked_pdf

Platform/distribution and version:

Heroku / Cedar-20
Current BuildPack: https://github.com/RohanDebroy/heroku-buildpack-wkhtmltopdf.git

Additional context

The issue appears to be related to missing dependencies in the wkhtmltopdf binary. The library libssl.so.1.1 is required but not present in the Heroku environment.

Is there a recommended way to ensure that libssl.so.1.1 is available, or is there an alternative version of wkhtmltopdf that does not have this dependency? Any guidance on resolving this would be appreciated.

@CarlosAwo
Copy link
Author

As I read on the buildpack creator's website, this buildpack only supports Heroku stacks up to and including version 22. The error occurred precisely when I migrated the Heroku stack from version 22 to version 24

@CarlosAwo
Copy link
Author

CarlosAwo commented Aug 22, 2024

Steps to Resolve Heroku Buildpack Compatibility Issues

  1. I Update the Gem: I update gem 'wkhtmltopdf-heroku' to version '3.0.0' in my Gemfile.

  2. I Remove the Unsupported Buildpack: I remove the buildpack that does not support Heroku 24.

    heroku buildpacks:remove <existing-buildpack-url> -a heroku-app-name
  3. I Add a New Buildpack: I add a new buildpack that supports Heroku 24.

    heroku buildpacks:add https://github.com/chap/wkhtmltopdf-heroku-18-buildpack --index 1 -a heroku-app-name
  4. I Create an Empty Commit: I create an empty commit with an appropriate message before deploying the app.

    git commit --allow-empty -m "Update buildpack for Heroku 24 compatibility"
  5. I Redeploy the App: I redeploy my application to activate the new buildpack.

    git push heroku main

Conclusion

By following these steps, I successfully resolved the compatibility issue with the Heroku 24 stack. Ensuring that the buildpack is compatible with the stack version is crucial to avoid deployment errors.

Advice for Others Facing Similar Issues

If you encounter similar issues, always check the compatibility of your buildpacks with the Heroku stack version you're using. Updating to the latest supported version and ensuring all dependencies are aligned with your stack version can prevent such errors. When making changes, remember to commit them properly, even if it’s an empty commit, to trigger a redeployment and ensure your changes take effect.

@CarlosAwo CarlosAwo changed the title BuildPack For Heroku-24 stack wkhtmltopdf Dependency Issue on Heroku-24 Stack Aug 22, 2024
@MisterGetman
Copy link

MisterGetman commented Oct 7, 2024

Steps to Resolve Heroku Buildpack Compatibility Issues

.....

Thanks! That's exactly what I was looking for! However it didn't run in development environment, so I had to add 'wkhtmltopdf-binary' to development group in Gemfile and specify different 'exe_path' in WickedPdf.config.
Thanks again!!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants