Skip to content

Instantly share code, notes, and snippets.

@boddhisattva
Last active August 29, 2015 14:27
Show Gist options
  • Save boddhisattva/e9e710364a0e6e822053 to your computer and use it in GitHub Desktop.
Save boddhisattva/e9e710364a0e6e822053 to your computer and use it in GitHub Desktop.
Fix for Bad wkhtmltopdf's path: /usr/bin/wkhtmltopdf error that comes when using wkhtmltopdf gem

If you're getting the error(see the image below) - Bad wkhtmltopdf's path: /usr/bin/wkhtmltopdf when using the wkhtmltopdf gem in your rails app to convert an HTML page to a PDF file. Following the below steps should help you get it working on your machine -

Bad wkhtmltopdf's path: /usr/bin/wkhtmltopdf

  • We need to first locate the bin file that converts HTML to pdf. This usually is present inside your wkhtmltopdf gem. For me this was located at - /Users/my_user_name/.rvm/gems/ruby-2.1.2@gemset_name/gems/wkhtmltopdf-0.1.2/bin
  • If you're using a mac, you'd need the darwin version of the bin file. Do a sudo cp wkhtmltopdf_darwin_386 /usr/bin/wkhtmltopdf.
    • This copies the bin from within the gem directory to the location where all local system bin files are generally present.
    • Please note: If you're using the another OS, you'd need to copy the appropriate bin file wrt the OS that you're using.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment