Rails: wkhtmltopdf RuntimeError (Location of wkhtmltopdf unknown)

dbaruah picture dbaruah · Oct 11, 2011 · Viewed 10.6k times · Source

I am using Ubuntu 11.04 to develop an app in Ruby on Rails. In the app I need to generate pdf documents. So I am using the wicked_pdf and wkhtmltopdf-binary gems.

In the development environment in my system everything is working fine. But once I deployed the app in production on CentOS 5.6 using Phusion Passenger, when I try to generate pdfs on the fly its giving me the following error:

RuntimeError (Location of wkhtmltopdf unknown)

I am using Ruby1.9.2.p136 Rails 3.1.1

Any help will be much appreciated....Thanks.

Answer

Skully picture Skully · Dec 27, 2013

An alternative is to install the binary via the Gemfile.

Just add the following line to your production group:

gem 'wkhtmltopdf-binary'

That should add binary support for linux-i386, amd64, and darwin.

And then run

bundle install --without development test

to install the gem in a production environment. After which, you just restart your server.

That's all.

I hope this helps