问题
I have a local Rails app that utilizes WickedPDF for some PDF generation in a Sidekiq job. When I run my app locally, it works just fine and all my RSpec tests pass. When I try to spin up the app in a Docker container, there's some strange behavior:
The Sidekiq jobs occassionally fail with an error and go back in to the "retry" queue. Over time, they all eventually get successfully processed, but it takes a lot of failed (expensive) attempts to do so. Is there any way to fix the error below, to prevent these errors from occuring?
RuntimeError: Failed to execute: ["/usr/bin/wkhtmltopdf", "--margin-top", "30", "--margin-bottom", "10", "file:////tmp/wicked_pdf20200221-1-170ippe.html", "/tmp/wicked_pdf_generated_file20200221-1-aikfq3.pdf"]
Error: PDF could not be generated! Command Error: QStandardPaths: XDG_RUNTIME_DIR not set, defaulting to '/tmp/runtime-root'
来源:https://stackoverflow.com/questions/60334567/wickedpdf-in-docker-sometimes-fails-generating-a-pdf-attachment