Fix „command failed: /usr/bin/wkhtmltopdf ...“ using PDFKit middleware
Ubuntu 12.04 LTS x64, Ruby 1.8.7, Rails 2.13, PDFKit 0.5.4, Phusion Passenger Apache 2
I ran into this, when I started using passenger to deal with the
Single Thread Issue
Archive
which caused my webrick to deadlock when an ActionController::RoutingError (No route matches "...")
occurred.
These steps brought me a little further
(1) assert dependencies are installed
Copysudo aptitude install openssl build-essential xorg libssl-dev
(2) only for 64bits OS Run one by one the following commands:
Copysudo wget http://wkhtmltopdf.googlecode.com/files/wkhtmltopdf-0.9.9-static-amd64.tar.bz2 sudo tar xvjf wkhtmltopdf-0.9.9-static-amd64.tar.bz2 sudo mv wkhtmltopdf-amd64 /usr/local/bin/wkhtmltopdf sudo chmod +x /usr/local/bin/wkhtmltopdf
Tell PDFKit where to find your wkhtmltopdf:
CopyRails::Initializer.run do |config| require "pdfkit" config.middleware.use PDFKit::Middleware PDFKit.configure do |config| config.wkhtmltopdf = '/usr/local/bin/wkhtmltopdf' # <-- the fix end end
Note
The wkhtmltopdf
in /usr/bin/wkhtmltopdf
is the version you installed with apt-get install wkhtmltopdf
and the version in /usr/local/bin/wkhtmltopdf
is, as you probably know, the version you installed running the (2) steps.
Important Note
I still got this error when an ActionController::RoutingError (No route matches "...")
occurred, e.g. missing a file like image, css, etc. because of broken PDFKit v0.5.4. At the moment I'm fine with v0.5.1.
makandra has been working exclusively with Ruby on Rails since 2007. Our laser focus on a single technology has made us a leader in this space.