ruby-on-railswicked-pdfwkhtmltopdf-binary

wkhtmltopdf-binary not being found on development server


Testing on localhost is running wicked-pdf gem output as expected. It has a dependency to wkhtmltopdf.

As per the indications here I determined and verified the existence on the Ubuntu 18.04 development server of this directory:

~/.rbenv/versions/2.6.1/lib/ruby/gems/2.6.0/gems/wkhtmltopdf-binary-0.12.5.4/bin 

then changed access rights

chmod -R 777 ~/.rbenv/versions/2.6.1/lib/ruby/gems/2.6.0/gems/wkhtmltopdf-binary-0.12.5.4/bin

Yes, bundle install returns

Using wkhtmltopdf-binary 0.12.5.4

which wkhtmltopdf returns

/home/deploy/.rbenv/shims/wkhtmltopdf

While the wickedPDF gem instructions encourages to create an initializer. However directory /usr/local/bin/ only has two documents in it : bundle and bundler. So I am clueless as to what is going on...

Still accessing an action calling a .pdf extension returns the error

RuntimeError in [class]Controller#pdf
Location of wkhtmltopdf unknown

how can wkhtmltopdf be properly accessed?


Solution

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