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
No wkhtmltopdf executable found #123
Comments
I'm also seeing the same problem on our prod server (Ruby 1.8.7p352, Rails 3.0.10, PDFKit 0.5.2, wkhtmltopdf 0.9.6). I didn't used to have this issue in prod with our Rails 2.3.2 app with wkhtmltopdf 0.9.6, but we recently upgraded. What's odd is that if I run a simple HTML to PDF conversion from the rails console (in production environment), it works just fine. Could this error message be masking another error? -a |
Also seeing this issue on Rails 2.3.10, PDFKit 0.5.2 and wkhtmltopdf 0.9.6. Found the problem was with line 20 of configuration.rb
|
Ha! I was just about to post a similar solution. Mine's more static, but ultimately the same thing: if Rails.env.production?
PDFKit.configure do |config|
config.wkhtmltopdf = '/usr/local/bin/wkhtmltopdf'
end
end ...in my config/initializers/pdfkit.rb :) I prefer your solution @stuart since it works in all environments without a messy conditional. -a |
Stuart hit the problem. @wkhtmltopdf ||= (defined?(Bundler::GemfileError) ?bundle187 exec which wkhtmltopdf:which wkhtmltopdf`).chomp Now it works in my case. |
Good day to all! I have tried the solutions you provided above and still I'm experiencing the same issue. May you please help me fix this issue(No wkhtmltopdf executable found)? FYI, I'm using windows pc and have successfully installed the wkhtmltopdf. Thanks, Vic |
I'm hitting this same problem. I have a user setup on my Linux system named deploy, with RVM and Ruby 1.9.3 install there. I have the gem 'wkhtmltopdf-binary' and gem 'pdfkit' in my Gemfile, both are installed on the system. When I attempt to render the HTML file to a PDF I'm told:
|
Good day, Troy! Please see below for the setup process I have implemented on my windows PC to fix the above issue. PDF KIT
Middle ware for PDF Kitconfig.middleware.use 'PDFKit::Middleware' PDF KitPDFKit.configure do |config| config.root_url = "http://localhost" # Use only if your external hostname is unavailable on the server.}
ActionController::Base.asset_host = Proc.new { |source, request|
<%= link_to "Download Invoice (PDF)", order_path(@order, :format => "pdf") %> References: https://github.com/pdfkit/PDFKit I hope the above process will fix the issue you have on your Linux system. Regards, Vic Abana |
@viclnp that helped me get a little further. I've removed the wkhtmltopdf-executable gem from my Gemfile, then re-deployed to my server via Capistrano. However now I'm getting this message when trying to generate a PDF: RuntimeError (command failed: "/home/deploy/apps/myapp/shared/bundle/ruby/1.9.1/bin/wkhtmltopdf" "--page-size" "Letter" "--margin-top" "0.75in" "--margin-right" "0.75in" "--margin-bottom" "0.75in" "--margin-left" "0.75in" "--encoding" "UTF-8" "--print-media-type" "--quiet" "-" "-"): Not sure why that's still show up there, I thought removing it from my Gemfile would remove it. If I do |
@talltroym - On your local PC, please generate pdf using your terminal? If the same issue occurs, then can you move the directory of your wktmltopdf to your local drive or to your desktop then change the directory of the config.wkhtmltopdf you defined in the pdfkit.rb from config/initializers. Hope that helps and will fix the issue. Vic Abana |
@viclnp - thanks for the replies. I setup a new virtual server and I was able to configure this to work. I think the problem is on my production server in the Gemfile I had the "wkhtmltopdf-executable" in the Gemfile, so it installed there. Now I've removed it from the Gemfile, but that didn't remove the gem from the system (I'm using Capistrano). I'll either figure out how to remove that one gem in that shared directory, or wipe out the app and re-deploy it without that gem, but having the wkhtmltopdf installed on the server like your directions show. This is what I did on the virtual server to get it to work. |
@talltroym - You are welcome! :) |
Hi, I am having real trouble getting PDFkit to work with ruby on Windows 7 system. I am trying to follow the steps above but have no idea what to do at step 4:
PDF Kit PDFKit.configure do |config| } Where is config/initializers ?? i cannot find it anywhere. Appreciate any help. Thanks |
That should be in the root of your Ruby on Rails app structure, config folder then initializers folder under that On Jan 26, 2013, at 7:27 PM, Blakey notifications@github.com wrote:
|
OK that explains why i cannot find it. I am not running rails (Not ready for building a web app yet - just trying to speed my life up a bit with a nifty bit of programming). Is PDFKit not going to work without rails? Or do i just need to update the config elsewhere? Sorry - pretty new to all of this! |
You don't need to be in Rails. You just need to run the "PDFKit.configure do |config| ... " block from your code prior to using PDFkit. |
Thanks guys. I have tried running from my code with no success. I'm going to start from scratch again and will hopefully see what has gone wrong. Will report back soon :) Update: I deleted, re-installed everything and used above code and it wokrs perfectly now. Thanks sodabrew and talltroym |
Hi folks, sorry to resurrect an old thread. I have the same issue that Blakey had, but which file do I paste the PDFKit.configure do stuff into? Cheers! |
Just read this @mcljot. Is this resolved? Thanks. |
Hey, more or less resolved – through another method! Thanks! From: Vic Abana [mailto:notifications@github.com] Just read this @mcljothttps://urldefense.proofpoint.com/v2/url?u=https-3A__github.com_mcljot&d=CwMCaQ&c=0YGvTs3tT-VMy8_v51yLDw&r=ucoheL-CAyLyDRiVDhh6tGC4vjlKuq8AWAspOX8m5cM&m=exxMCoH0e_8nKAQHj3VwN8rihx8ZqKD36dWcW9uRNnQ&s=LHV0VPI3unL1rRqB8Z0e_gOYhV7gdUZu_yayAwnZck4&e=. Is this resolved? Thanks. — This e-mail contains privileged and confidential information intended for the use of the addressees named above. If you are not the intended recipient of this e-mail, you are hereby notified that you must not disseminate, copy or take any action in respect of any information contained in it. If you have received this e-mail in error, please notify the sender immediately by e-mail and immediately destroy this e-mail and its attachments. |
Great to hear @mcljot! 👍 |
Hi, A couple years latter I'm having a similar issue with this line again:
I'm using > `which wkhtmltopdf`
=> "/home/deploy/.rbenv/versions/2.6.4/bin/wkhtmltopdf\n" But from by Rails console if I do the > `bundle exec which wkhtmltopdf`
/home/deploy/.rbenv/versions/2.6.4/lib/ruby/gems/2.6.0/gems/bundler-2.1.4/lib/bundler/vendor/fileutils/lib/fileutils.rb:105: warning: already initialized constant Bundler::FileUtils::VERSION
/home/deploy/.rbenv/versions/2.6.4/lib/ruby/gems/2.6.0/gems/bundler-2.0.2/lib/bundler/vendor/fileutils/lib/fileutils/version.rb:4: warning: previous definition of VERSION was here
/home/deploy/.rbenv/versions/2.6.4/lib/ruby/gems/2.6.0/gems/bundler-2.1.4/lib/bundler/vendor/fileutils/lib/fileutils.rb:1284: warning: already initialized constant Bundler::FileUtils::Entry_::S_IF_DOOR
/home/deploy/.rbenv/versions/2.6.4/lib/ruby/gems/2.6.0/gems/bundler-2.0.2/lib/bundler/vendor/fileutils/lib/fileutils.rb:1267: warning: previous definition of S_IF_DOOR was here
/home/deploy/.rbenv/versions/2.6.4/lib/ruby/gems/2.6.0/gems/bundler-2.1.4/lib/bundler/vendor/fileutils/lib/fileutils.rb:1568: warning: already initialized constant Bundler::FileUtils::Entry_::DIRECTORY_TERM
/home/deploy/.rbenv/versions/2.6.4/lib/ruby/gems/2.6.0/gems/bundler-2.0.2/lib/bundler/vendor/fileutils/lib/fileutils.rb:1547: warning: previous definition of DIRECTORY_TERM was here
/home/deploy/.rbenv/versions/2.6.4/lib/ruby/gems/2.6.0/gems/bundler-2.1.4/lib/bundler/vendor/fileutils/lib/fileutils.rb:1626: warning: already initialized constant Bundler::FileUtils::OPT_TABLE
/home/deploy/.rbenv/versions/2.6.4/lib/ruby/gems/2.6.0/gems/bundler-2.0.2/lib/bundler/vendor/fileutils/lib/fileutils.rb:1602: warning: previous definition of OPT_TABLE was here
/home/deploy/.rbenv/versions/2.6.4/lib/ruby/gems/2.6.0/gems/bundler-2.1.4/lib/bundler/vendor/fileutils/lib/fileutils.rb:1685: warning: already initialized constant Bundler::FileUtils::LOW_METHODS
/home/deploy/.rbenv/versions/2.6.4/lib/ruby/gems/2.6.0/gems/bundler-2.0.2/lib/bundler/vendor/fileutils/lib/fileutils.rb:1656: warning: previous definition of LOW_METHODS was here
/home/deploy/.rbenv/versions/2.6.4/lib/ruby/gems/2.6.0/gems/bundler-2.1.4/lib/bundler/vendor/fileutils/lib/fileutils.rb:1692: warning: already initialized constant Bundler::FileUtils::METHODS
/home/deploy/.rbenv/versions/2.6.4/lib/ruby/gems/2.6.0/gems/bundler-2.0.2/lib/bundler/vendor/fileutils/lib/fileutils.rb:1663: warning: previous definition of METHODS was here
Traceback (most recent call last):
9: from /home/deploy/.rbenv/versions/2.6.4/bin/bundle:23:in `<main>'
8: from /home/deploy/.rbenv/versions/2.6.4/bin/bundle:23:in `load'
7: from /home/deploy/.rbenv/versions/2.6.4/lib/ruby/gems/2.6.0/gems/bundler-2.1.4/exe/bundle:13:in `<top (required)>'
6: from /home/deploy/.rbenv/versions/2.6.4/lib/ruby/gems/2.6.0/gems/bundler-2.1.4/exe/bundle:13:in `require_relative'
5: from /home/deploy/.rbenv/versions/2.6.4/lib/ruby/gems/2.6.0/gems/bundler-2.1.4/lib/bundler.rb:7:in `<top (required)>'
4: from /home/deploy/.rbenv/versions/2.6.4/lib/ruby/gems/2.6.0/gems/bundler-2.1.4/lib/bundler.rb:7:in `require_relative'
3: from /home/deploy/.rbenv/versions/2.6.4/lib/ruby/gems/2.6.0/gems/bundler-2.1.4/lib/bundler/errors.rb:3:in `<top (required)>'
2: from /home/deploy/.rbenv/versions/2.6.4/lib/ruby/gems/2.6.0/gems/bundler-2.1.4/lib/bundler/errors.rb:20:in `<module:Bundler>'
1: from /home/deploy/.rbenv/versions/2.6.4/lib/ruby/gems/2.6.0/gems/bundler-2.1.4/lib/bundler/errors.rb:20:in `<class:GemfileError>'
/home/deploy/.rbenv/versions/2.6.4/lib/ruby/gems/2.6.0/gems/bundler-2.1.4/lib/bundler/errors.rb:9:in `status_code': Trying to register Bundler::GemfileError for status code 4 but Bundler::GemfileError is already registered (ArgumentError)
=> "" I'm using bundler I see I'm not the first to have the problem and everyone is circumventing the problem with hack and hardcoding the path (eg https://stackoverflow.com/questions/32429977/why-cant-bundler-find-wkhtmltopdf-on-server?rq=1). Isn't it time we fix this? In my case it seems it was running bundle exec from an ENV already started using bundler ( But PDFKit still provides the wrong error message which doesn't help, also if Something like: def default_wkhtmltopdf
return @default_command_path if @default_command_path
if defined?(Bundler::GemfileError) && File.exists?('Gemfile')
@default_command_path = `bundle exec which wkhtmltopdf`.chomp
end
@default_command_path = `which wkhtmltopdf` if @default_command_path&.empty?
end What do you think? |
@jarthod Thanks for this suggestion. Can you make a PR with this change? |
I'm using rails 3.0.9 and ruby 1.8.7 and I'm getting this error:
No wkhtmltopdf executable found at
The executable is installed and accessible (in the PATH) and it have 755 permissions.
The text was updated successfully, but these errors were encountered: