Hommer Smith
Hommer Smith

Reputation: 27852

Environment conflicts with WickedPDF and Heroku

I am using WickedPDF, and I have basically two gems that include the binaries:

gem "wkhtmltopdf-heroku", "1.0.0"
gem "wkhtmltopdf-binary", "0.9.5.3"

The first one is supposed to be just for production, and the second one for development. The deployment to Heroku doesn't work if I have my Gemfile like:

group :development do
  gem "wkhtmltopdf-binary", "0.9.5.3"
end

group :production do
  gem "wkhtmltopdf-heroku", "1.0.0"
end

And it doesn't work either if I have it like:

group :production do
  gem "wkhtmltopdf-heroku", "1.0.0"
end

It just works if I have it without groups. Just like:

gem "wkhtmltopdf-heroku", "1.0.0"

The error that I get is:

RuntimeError: Location of wkhtmltopdf unknown

Why would this happen? Why Heroku is not using the production group?

Upvotes: 3

Views: 1014

Answers (1)

Unixmonkey
Unixmonkey

Reputation: 18784

WickedPdf tries to figure out where the wkhtmltopdf binary lives, but can have a hard time on some systems (particularly shared servers).

You probably have to set it manually in an initializer something like this:

bin_location = case Rails.env
  when 'production' then "/wherever/your/binary/is/bin/wkhtmltopdf"
  when 'development' then "/local/path/to/wkthmltopdf"
  else `which wkhtmltopdf`
end
WickedPdf.config = { :exe_path => bin_location }

Upvotes: 2

Related Questions