生产中 wkhtmltopdf-binary gem 的问题

an issue with the wkhtmltopdf-binary gem in the production

我正在使用 gem 'wicked_pdf' 将 html 转换为 pdf。 它在开发模式下运行良好。但在生产中它抛出错误 nginx.This 是生产中的错误日志:

I, [2017-10-17T12:34:09.726920 #17004]  INFO -- : [4a94b9f6-fdf6-4e55-b325-9b3096132d4e] Completed 500 Internal Server Error in 2638ms (ActiveRecord: 30.6ms)
F, [2017-10-17T12:34:09.729566 #17004] FATAL -- : [4a94b9f6-fdf6-4e55-b325-9b3096132d4e]   
F, [2017-10-17T12:34:09.729763 #17004] FATAL -- : [4a94b9f6-fdf6-4e55-b325-9b3096132d4e] RuntimeError (Failed to execute:
["/home/deploy/phoenix/shared/bundle/ruby/2.4.0/bin/wkhtmltopdf", "-q", "file:////tmp/wicked_pdf20171017-17004-ps7ahv.html", "/tmp/wicked_pdf_generated_file20171017-17004-17rkfch.pdf"]
Error: PDF could not be generated!
Command Error: /home/deploy/phoenix/shared/bundle/ruby/2.4.0/gems/wkhtmltopdf-binary-0.12.3.1/bin/wkhtmltopdf_linux_amd64: error while loading shared libraries: libXrender.so.1: cannot open shared object file: No such file or directory
):
F, [2017-10-17T12:34:09.729900 #17004] FATAL -- : [4a94b9f6-fdf6-4e55-b325-9b3096132d4e]   
F, [2017-10-17T12:34:09.730005 #17004] FATAL -- : [4a94b9f6-fdf6-4e55-b325-9b3096132d4e] app/controllers/orders_controller.rb:16:in `block (2 levels) in show'
[4a94b9f6-fdf6-4e55-b325-9b3096132d4e] app/controllers/orders_controller.rb:13:in `show'

我猜测我有一个缺少库的问题:libXrender.so.1

我在制作中使用 ubuntu 16.04 ruby:2.4.1 和 rails 5.1.4 我可以得到你的支持吗?

听起来您的生产服务器没有安装 xserver。

sudo apt-get install libxrender1

应该在 Ubuntu 上为您工作。