Ruby on rails Wkhtmltopdf libpng15.so与Rails 6.1的错误
我最近将我的Rails应用程序从6.0升级到6.1,升级后,每当我试图生成PDF时,都会出现以下错误:Ruby on rails Wkhtmltopdf libpng15.so与Rails 6.1的错误,ruby-on-rails,wkhtmltopdf,ruby-on-rails-6,wicked-pdf,Ruby On Rails,Wkhtmltopdf,Ruby On Rails 6,Wicked Pdf,我最近将我的Rails应用程序从6.0升级到6.1,升级后,每当我试图生成PDF时,都会出现以下错误: RuntimeError:未能执行:[“/opt/rubies/ruby-2.6.6/bin/wkhtmltopf”、“--方向”、“横向”、“--页眉顶部”、“25”、“--页眉底部”、“10”、“--页眉间距”、“3”、“--页眉html”、”file:////tmp/wicked_header_pdf20210506-22237-1tx5wdw.html“,”--页脚html“,”fil
RuntimeError:未能执行:[“/opt/rubies/ruby-2.6.6/bin/wkhtmltopf”、“--方向”、“横向”、“--页眉顶部”、“25”、“--页眉底部”、“10”、“--页眉间距”、“3”、“--页眉html”、”file:////tmp/wicked_header_pdf20210506-22237-1tx5wdw.html“,”--页脚html“,”file:////tmp/wicked_footer_pdf20210506-22237-1fo4wp6.html", "file:////tmp/wicked_pdf20210506-22237-1c7ctor.html“,”/tmp/wicked_pdf_生成的文件20210506-22237-1c2hpwj.pdf“]错误:无法生成PDF!命令错误:/opt/rubies/ruby-2.6.6/lib/ruby/gems/2.6.0/gems/wkhtmltopf-binary-0.12.6.5/bin/wkhtmltopdf_centos_7_amd64:加载共享库时出错:libpng15.so.15:无法打开共享对象文件:没有此类文件或目录
我尝试通过以下链接遵循以下步骤:手动安装libpng,但问题仍然存在
#wkhtmltopdfhttps://majestic.cloud majestic.pdf/opt/rubies/ruby-2.6.6/lib/ruby/gems/2.6.0/gems/wkhtmltopf-binary-0.12.6.5/bin/wkhtmltopf_centos_7_amd64:加载共享库时出错:libpng15.so.15:无法打开共享对象文件:没有此类文件或目录
以下是我的Gemfile的外观:
ruby '2.6.6'
gem 'rails', '~> 6.1', '>= 6.1.3.1'
gem 'wicked_pdf', '~> 2.0', '>= 2.0.1'
gem 'wkhtmltopdf-binary'
这是我的config/initializers/wicked_pdf.rb
if Rails.env.production?
WickedPdf.config = {
exe_path: '/opt/rubies/ruby-2.6.6/bin/wkhtmltopdf'
}
end
由于该应用程序托管在ElasticBeanstalk上,因此已通过ebextensions设置了权限
container_commands:
03_set_wkhtmltopdf_binary_permissions:
command: "chmod -R 777 /opt/rubies/ruby-2.6.6/lib/ruby/gems/2.6.0/gems/wkhtmltopdf-binary-0.12.6.5/bin/"
出现问题是因为版本不匹配。下面将介绍更多内容: 下面是我的工作:
Gemfile
gem 'wicked_pdf', '~> 2.0', '>= 2.0.1'
gem 'wkhtmltopdf-binary', '0.12.6'
Gemfile.lock
wicked_pdf (2.1.0)
activesupport
wkhtmltopdf-binary (0.12.6)
wicked_pdf (~> 2.0, >= 2.0.1)
wkhtmltopdf-binary (= 0.12.6)
.ebextensions/commands.config
03_set_wkhtmltopdf_binary_permissions:
command: "chmod -R 777 /opt/rubies/ruby-2.6.6/lib/ruby/gems/2.6.0/gems/wkhtmltopdf-binary-0.12.6/bin/"