Rails: wkhtmltopdf RuntimeError (Location of wkhtmltopdf unknown)
do you use static wkhtmltopdf binary? i downloaded it here and extraced it to /path/to/rails_app/bin
and add it to rails like this:
#config/initializers/wicked_pdf.rb
WickedPdf.config = {
:exe_path => Rails.root.join('bin', 'wkhtmltopdf-i386').to_s,
}
wkhtmltopdf-binary not being found on development server
All the elements of solution were in the question.
One forgotten element was that the server was multiuser and wkhtmltopdf was originally installed by another user. As the wkhtmltopdf gem page states, there is a permissions issue during installation; it is then observed that those permissions were assigned to the other user.
As per link to wicked PDF gem, creating an initializer containing:
WickedPdf.config = {
exe_path: '/home/deploy/.rbenv/shims/wkhtmltopdf'
}
solved the issue.
WKHTMLTOPDF path in ROR application
In the source of wkhtmltopdf it looks like all it is doing is running File.exists? on that path:
https://github.com/mileszs/wicked_pdf/blob/56aa1a195d65eaaf33fbd0254e1e7df99ce1fd1c/lib/wicked_pdf.rb#L41
So we gotta double check the assumption that wkhtmltopdf is correctly installed at /usr/local/bin/wkhtmltopdf
Could you give a bit more information? Just to verify, what is the output of which wkhtmltopdf
And when you run wkhtmltopdf -V
in the console, what do you get?
You could try specifying the path in the configuration (in an initializer as mentioned in the wkhtmltopdf readme) just to see if that makes a difference too.
And lastly you could move the executable to a different directory, and then specify that in the initializer to see if it maybe has something to do with folder permissions.
Environment conflicts with WickedPDF and Heroku
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 }
an issue with the wkhtmltopdf-binary gem in the production
It sounds like your production server doesn't have an xserver installed.
sudo apt-get install libxrender1
should work for you on Ubuntu.
Related Topics
How to Use Link_To to Link an Image and a Text
Sorting a Hash in Ruby by Its Value First Then Its Key
How to Convert a Scientific Notation String to Decimal Notation
Rails Devise - Current_User Is Nil
What Are Symbols and How Do We Use Them
How to Update to Ruby 2.1.2 Using Rails 3.2.3
Rvm Error While Running Make Install. Error Comes While Installing Power_Assert Gem
How to Shorten a Uuid to a Specific Length
Gem Which Cannot Find Gem Despite It Being Installed
How to Tell Which Openssl Lib Is Actually Being Used by an Rvm-Installed Ruby
How to Source Environment Variables for a Command Shell in a Ruby Script
Rails Active Record: Find in Conjunction with :Order and :Group
Convert Array-Of-Hashes to a Hash-Of-Hashes, Indexed by an Attribute of the Hashes
Converting String "2½" (Two and a Half) into 2.5
Spacing Around Parentheses in Ruby
How to Populate an Array with Random Numbers