Posted about 6 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 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: Rails::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.

Growing Rails Applications in Practice
Check out our new e-book:
Learn to structure large Ruby on Rails codebases with the tools you already know and love.

Owner of this card:

Avatar
Martin Straub
Last edit:
about 5 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 cookies to improve usability and analyze traffic.
Accept or learn more