Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Failure to locate wkhtmltopdf binary in certain environments using bundler #730

Closed
glossawy opened this issue Mar 20, 2018 · 1 comment
Closed

Comments

@glossawy
Copy link

glossawy commented Mar 20, 2018

When upgrading our bundler version (we were running quite an old version in some environments, namely 1.10.x) we ran into an issue where apps using wicked_pdf would fail due to a failure to locate the wkhtmltopdf binary. We discovered this was because of changes introduced in bundler 1.14.x where a warning is output by bundler if the home directory is not writable/not found/etc., specifically by rubygems/bundler#4951.

This appears to be because of how wicked_pdf attempts to locate wkhtmltopdf, using the shell and executing which within the context of a bundle. In the right conditions this will pick up the warning output by bundler, which clearly leads to an invalid path.

Per pdfkit/pdfkit#388, you can observe the problem by doing the following:

# Set up gems with a real reference to wkhtmltopdf
gem install bundler --version 1.14.3
echo "source 'https://rubygems.org';\ngem 'wkhtmltopdf-binary-edge'" > Gemfile
bundle install --path vendor/bundle

# See the UI printout
HOME=/no/directory/found bundle exec which wkhtmltopdf

Leading to an output along the lines of

Your home directory is not set properly:
 * `/no/directory/found` is not a directory

Bundler will use `/var/folders/wj/q7cqmwds75z3ndcdxrmpd9gh0000gn/T/bundler/home/rdimarco` as your home directory temporarily

I have proposed a possible fix with associated tests at #728. Though there is a workaround, it may be worth it to not use bundle exec which wkhtmltopdf.

Workaround

The obvious workaround is to specify the binary path in WickedPdf.config per the readme.

@unixmonkey
Copy link
Collaborator

Closing since #728 was merged. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants