Posted over 7 years ago. Visible to the public.

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 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

sudo aptitude install openssl build-essential xorg libssl-dev

(2) only for 64bits OS Run one by one the following commands:

sudo wget 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:

Copy do |config| require "pdfkit" config.middleware.use PDFKit::Middleware PDFKit.configure do |config| config.wkhtmltopdf = '/usr/local/bin/wkhtmltopdf' # <-- the fix end end


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.

Does your version of Ruby on Rails still receive security updates?
Rails LTS provides security patches for old versions of Ruby on Rails (3.2 and 2.3).

Owner of this card:

Martin Straub
Last edit:
over 6 years ago
About this deck:
We are makandra and do test-driven, agile Ruby on Rails software development.
License for source code
Posted by Martin Straub to makandra dev
This website uses short-lived cookies to improve usability.
Accept or learn more