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

PDF Rendering Fail on Heroku-24 Stack #1125

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

PDF Rendering Fail on Heroku-24 Stack #1125

CarlosAwo opened this issue Aug 22, 2024 · 5 comments

Comments

@CarlosAwo
Copy link

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

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 wkhtmltopdf Dependency Issue on Heroku-24 Stack PDF Rendering Fail on Heroku-24 Stack Aug 22, 2024
@Vicky099
Copy link

I upgraded my Ubuntu from 22 to 24 at local and PDF generation in broken state.

/gems/wkhtmltopdf-binary-0.12.6.6/bin/wkhtmltopdf:69:in `<top (required)>': Invalid platform, must be running on Ubuntu 16.04/18.04/20.04/22.04, CentOS 6/7/8, Debian 9/10, Archlinux amd64, or Intel-based Cocoa macOS (missing binary: /home/vicky/.rvm/gems/ruby-3.2.2@eventmanagement/gems/wkhtmltopdf-binary-0.12.6.6/bin/wkhtmltopdf_ubuntu_24.04_amd64). (RuntimeError)

@unixmonkey
Copy link
Collaborator

I upgraded my Ubuntu from 22 to 24 at local and PDF generation in broken state.

/gems/wkhtmltopdf-binary-0.12.6.6/bin/wkhtmltopdf:69:in `<top (required)>': Invalid platform, must be running on Ubuntu 16.04/18.04/20.04/22.04, CentOS 6/7/8, Debian 9/10, Archlinux amd64, or Intel-based Cocoa macOS (missing binary: /home/vicky/.rvm/gems/ruby-3.2.2@eventmanagement/gems/wkhtmltopdf-binary-0.12.6.6/bin/wkhtmltopdf_ubuntu_24.04_amd64). (RuntimeError)

@Vicky099 bundle update wkhtmltopdf_binary

@Vicky099
Copy link

Yes I did same. forgot to update here. Thanks for reply 🎉

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

3 participants