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

Support Heroku-22 stack #55

Closed
guillaumewrobel opened this issue Jun 22, 2022 · 28 comments
Closed

Support Heroku-22 stack #55

guillaumewrobel opened this issue Jun 22, 2022 · 28 comments

Comments

@guillaumewrobel
Copy link

guillaumewrobel commented Jun 22, 2022

Heroku-22 Stack has been released and it breaks the wkhtmltopdf-heroku gem with the following error message:

Failed to execute:
["/app/vendor/bundle/ruby/3.1.0/gems/wkhtmltopdf-heroku-2.12.6.0/bin/wkhtmltopdf-linux-amd64", "--page-size", "Letter", "file:////tmp/wicked_pdf20220622-6-3pxuf2.html", "/tmp/wicked_pdf_generated_file20220622-6-ko5r5s.pdf"]
Error: PDF could not be generated! Command Error: /app/vendor/bundle/ruby/3.1.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

Heroku explains this with:

OpenSSL 3
Ubuntu 22.04 ships with OpenSSL 3.0. OpenSSL 1.1 is not available as a runtime library.

If you see OpenSSL/libssl related errors (for example libssl.so.1.1: cannot open shared object file, but there will be many other variations), you will need to update your dependencies and/or third-party buildpacks to a version that is compatible with OpenSSL 3, and ensure that dependencies or binaries you use are compiled against OpenSSL 3.

In addition, OpenSSL 3 drops default support for a number of legacy/insecure cryptographic algorithms. If you see TLS/SSL related failures connecting from your application to external services, it is likely that those servers are running outdated/insecure software or configurations, that will need to be fixed by the maintainers of those services.

@pallymore tell me if I can help by suggesting a PR 🙏

@pallymore
Copy link
Collaborator

hmm this is tricky. I don't think that's something we can resolve in this repository - this gem simply ships the binary from https://github.com/wkhtmltopdf/wkhtmltopdf , unfortunately that repo is in a semi-abandoned state.

We could try to compile a binary from source with openssl 3 but it still might not work due to the breaking changes mentioned in the article 🤔

@pallymore
Copy link
Collaborator

Looks like someone has already compiled a binary for Ubuntu 22: wkhtmltopdf/packaging#114

testing that shortly.

@pallymore
Copy link
Collaborator

Hi - I think it actually works - here's a test page:

https://wkhtmltopdf-demo.herokuapp.com/greetings/hello.pdf

could you test this on your end also? here's my test "app":
https://github.com/pallymore/wkhtmltopdf-test

could you try it with: https://github.com/pallymore/wkhtmltopdf-test/blob/main/Gemfile#L29

gem 'wkhtmltopdf-heroku',  git: 'https://github.com/rposborne/wkhtmltopdf-heroku.git', branch: '2.12.6.0-jammy'

@ashkulz
Copy link

ashkulz commented Jun 23, 2022

@pallymore there's an official release for 22.04 published just now.

@pallymore
Copy link
Collaborator

thanks - checking if those binaries work 🤔

@pallymore
Copy link
Collaborator

Hi @ashkulz - the latest release does not work on Heroku-22.
I'm getting the same libssl 1.1 error - for now i've reverted the binary back: https://github.com/rposborne/wkhtmltopdf-heroku/commits/2.12.6.0-jammy

@guillaumewrobel please let me know if that branch works for you:

gem 'wkhtmltopdf-heroku',  git: 'https://github.com/rposborne/wkhtmltopdf-heroku.git', branch: '2.12.6.0-jammy'

@ashkulz
Copy link

ashkulz commented Jun 24, 2022

@pallymore yeah, there were some issues and I've deleted the release.

@guillaumewrobel
Copy link
Author

@pallymore the 2.12.6.0-jammy branch works well 👍

@pallymore
Copy link
Collaborator

awesome, for now i've published the branch as version 2.12.6.0.pre.jammy until an official binary is available.

https://rubygems.org/gems/wkhtmltopdf-heroku/versions/2.12.6.0.pre.jammy

@ashkulz
Copy link

ashkulz commented Jun 29, 2022

@pallymore please check again with the latest build.

@pallymore
Copy link
Collaborator

Hi @ashkulz the latest release works! thank you!

@pallymore
Copy link
Collaborator

Released: https://rubygems.org/gems/wkhtmltopdf-heroku/versions/2.12.6.1.pre.jammy

Thanks!

Is there going to be a Ubuntu 20 (Focal) AMD64 build?

@ashkulz
Copy link

ashkulz commented Jun 30, 2022

@pallymore there is already a Ubuntu 20.04 build which was part of the original 0.12.6 release ... not sure what you mean? 🤔

@pallymore
Copy link
Collaborator

nvm, I thought this release is for 0.12.6.1 and the original release was 0.12.6.0 😅 we are good here if they are built from the same source.

thank you again.

@ashkulz
Copy link

ashkulz commented Jun 30, 2022

Yeah, the only changes in the 0.12.6.x branch is some fixes to get it working with newer compiler versions.

@toddsutt
Copy link

Hi there, not sure if anyone will see this but I just upgraded my heroku to 22 stack and tried to add the experimental gem to my gemfile and redeploy but I am still getting the same error. I might be missing something can anyone help?

gem 'wicked_pdf'
gem 'wkhtmltopdf-binary'
gem 'wkhtmltopdf-heroku', '2.12.6.1.pre.jammy' # experimental support for heroku stack 22

@pallymore
Copy link
Collaborator

@toddsutt I see you are using both wkhtmltopdf-binary and wkhtmltopdf-heroku
I'd check which one is being picked up by wicked_pdf

I'd recommend keeping wkhtmltopdf-binary in the :development and :test gem group, and only use wkhtmltopdf-heroku in production.

@toddsutt
Copy link

@pallymore thank you for the response! As you can see, I don't understand what these gems are doing, so I will give that a try!

@toddsutt
Copy link

@pallymore after your suggestion I get this error on heroku:

Command Error: /app/vendor/bundle/ruby/3.1.0/gems/bundler-2.3.10/lib/bundler/rubygems_integration.rb:319:in `block in replace_bin_path': can't find executable wkhtmltopdf for gem wkhtmltopdf-binary. wkhtmltopdf-binary is not currently included in the bundle, perhaps you meant to add it to your Gemfile? (Gem::Exception)

@pallymore
Copy link
Collaborator

yea looks like it's still trying to find wkhtmltopdf-binary - I'd check where it is still referenced in the code.
what's in your wicked_pdf config file?

@toddsutt
Copy link

toddsutt commented Sep 21, 2022

@pallymore again, thank you so much for helping me I really appreciate it.

Here is the relevant part of my gemfile:

group :development do
  # Access an interactive console on exception pages or by calling 'console' anywhere in the code.
  gem 'web-console', '>= 3.3.0'
  gem 'listen', '>= 3.0.5', '< 3.2'
  # Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring
  gem 'spring'
  gem 'spring-watcher-listen', '~> 2.0.0'
  gem 'wkhtmltopdf-binary'
end

group :test do
  # Adds support for Capybara system testing and selenium driver
  gem 'capybara', '>= 2.15'
  gem 'selenium-webdriver'
  # Easy installation and use of chromedriver to run system tests with Chrome
  gem 'chromedriver-helper'
end

# Windows does not include zoneinfo files, so bundle the tzinfo-data gem
gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby]
gem 'devise'
gem 'jquery-rails'
gem 'haml-rails'
gem 'font-awesome-rails', '~> 4.7.0'
gem 'will_paginate'
gem 'wicked_pdf'
gem 'wkhtmltopdf-heroku', '2.12.6.1.pre.jammy' # experimental support for heroku stack 22

wicked_pdf.rb is completely default:

# WickedPDF Global Configuration
#
# Use this to set up shared configuration options for your entire application.
# Any of the configuration options shown here can also be applied to single
# models by passing arguments to the `render :pdf` call.
#
# To learn more, check out the README:
#
# https://github.com/mileszs/wicked_pdf/blob/master/README.md

WickedPdf.config = {
  # Path to the wkhtmltopdf executable: This usually isn't needed if using
  # one of the wkhtmltopdf-binary family of gems.
  # exe_path: '/usr/local/bin/wkhtmltopdf',
  #   or
  # exe_path: Gem.bin_path('wkhtmltopdf-binary', 'wkhtmltopdf')

  # Layout file to be used for all PDFs
  # (but can be overridden in `render :pdf` calls)
  # layout: 'pdf.html',

  # Using wkhtmltopdf without an X server can be achieved by enabling the
  # 'use_xvfb' flag. This will wrap all wkhtmltopdf commands around the
  # 'xvfb-run' command, in order to simulate an X server.
  #
  # use_xvfb: true,
}

@toddsutt
Copy link

Do I need to do something to uninstall the binary gem from heroku after moving it to development? Like delete my Gemfile.lock?

@pallymore
Copy link
Collaborator

Sorry for the late response - in regards to the lock file, yea you will need to run bundle install after making the gemfile changes, and commit the new lock file.

I'd search wkhtmltopdf-binary in the codebase to see if it's still being referenced somewhere - assuming you've set the environment to production on Heroku, only wkhtmltopdf-heroku gem should be loaded.

@pallymore
Copy link
Collaborator

also could you DM me on twitter we can continue there if you are still having issues: https://twitter.com/Yuruiology 👋🏻

@toddsutt
Copy link

@pallymore I finally figured it out! Btw I couldn't message you on twitter it said I was unable to send messages even after following.

I tried a whole lot of things but it ended up just being that I needed to add exe_path: Gem.bin_path('wkhtmltopdf-heroku', 'wkhtmltopdf-linux-amd64') to my WickedPdf.config for production environment.

@pallymore
Copy link
Collaborator

great - I don't think exe_path is needed as this gem configures that for you automatically.

however I think I know the problem now - in your config you had:

WickedPdf.config = {
}

which overrides the whole config object - in the README file, it's recommended to extend the config instead
(see https://github.com/rposborne/wkhtmltopdf-heroku#when-using-with-wicked_pdf )

WickedPdf.config ||= {}
WickedPdf.config.merge!({
  # your extra configurations here
})

this should eliminate the needs of having to set an exe_path manually.

@nickyczeme
Copy link

What is the solution I have the same problem

@toddsutt
Copy link

What is the solution I have the same problem

@nickyczeme for me it was what @pallymore last said - I simply needed to remove the WickedPdf.config = {} from my initializer

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

5 participants