Open kannathasan-san opened 9 years ago
Could you try pointing your Gemfile
at the master branch and let me know if that helps?
The currently released gem versions are designed to work with wkhtmltopdf 0.9.9
and earlier, and we are working the kinks out for later versions at the moment.
gem 'wicked_pdf', github: 'mileszs/wicked_pdf'
Yes I tried the same.its throwing the same error..
The tempfiles aren't getting transformed into path strings correctly:
file:////tmp/["wicked_pdf", ".html"]
What version of Ruby are you using?
Ruby 1.9.3
I'm having trouble reproducing the issue. Do you have any global settings (like :temp_path
) set?
Can you paste the error you get against master
, too?
I'm having the same problem with Rails 4.1.0 and Ruby 2.1.5 I have used 3 hours trying to find the problem but no success.
gem 'wicked_pdf', github: 'mileszs/wicked_pdf'
gem 'wkhtmltopdf-binary'
"**[\"/Users/josegranado/.rvm/gems/ruby-2.1.5@rails4.1.0/bin/wkhtmltopdf\", \"-q\", \"file:////var/folders/2/4frrvtcx7t74xtyr3ppc39s80000gn/T/wickedpdf20150131-93017-19bgrrc.html\", \"/var/folders/2/4frrvtcx7t74xtyr3ppc39s80000gn/T/wicked_pdf_generatedfile20150131-93017-l5ynes.pdf\"]******" Completed 500 Internal Server Error in 895ms
RuntimeError - Error: Failed to execute:
["/Users/josegranado/.rvm/gems/ruby-2.1.5@rails4.1.0/bin/wkhtmltopdf", "-q", "file:////var/folders/2_/4frrvtcx7t74xtyr3ppc39s80000gn/T/wickedpdf20150131-93017-19bgrrc.html", "/var/folders/2/4frrvtcx7t74xtyr3ppc39s80000gn/T/wicked_pdf_generated_file20150131-93017-l5ynes.pdf"]
Error: PDF could not be generated!
Command Error: /Users/josegranado/.rvm/gems/ruby-2.1.5@global/gems/bundler-1.7.6/lib/bundler/source/git.rb:188:in rescue in load_spec_files': git://github.com/stefanpenner/country_select.git (at master) is not yet checked out. Run
bundle install` first. (Bundler::GitError)
The last line complains about a different gem, if I remove that gem it will complain about a different one. So that must be a consequence of the real problem above.
The funny thing is that I have another project using wicked just the same and it works all fine. But that is Rails 4.0.0 and Ruby 2.1.5
Both projects use their own gemset and each gem set contains its binary.
My config is like this:
if Rails.env.production?
WickedPdf.config = {
:exe_path => Rails.root.join('bin', 'wkhtmltopdf-amd64').to_s
}
else
WickedPdf.config = {
:exe_path => '/Users/josegranado/.rvm/gems/ruby-2.1.5@rails4.1.0/bin/wkhtmltopdf'
}
end
It is interesting that if entering to the console, rails c and executing: WickedPdf.new.pdf_from_string("test")
Seems to generate a pfd, but the same on a controller fails with the error above.
Any ideas?
UPDATE The problem seems to be caused by Spring. Removing the sping gem got wicked_pdf working again. I guess there's a way to have both but I didn't want to spend more time on this one.
@josegrad Weird. I wonder what spring
has to do with this?
Thanks for sharing that. I have a feeling it will help others.
Maybe it has something to do with bundle exec'ing the wkhtmltopdf
command, I'll look into that.
Brilliant! Same problem here. wicked_pdf kept complaining about some gem not being checked out on master. Removing spring from my Gemfile got wicked_pdf back to live. I was using wicked_pdf 0.11.0 with spring 1.3.4
Updating to spring 1.3.6 seems to fix this issue for me.
I had to disable spring too to make it work again :-(
updating to 1.3.6 did not work had to take spring out entirely, it worked initially on my computer, but when another dev on the project pulled the update down it broke :-/
getting the same issue even after removing/updating spring gem
same here, getting the same issue even after removing spring
updating spring and running bundle exec spring binstub --all
fixed my issue.
I got the same error. All i had to do was kill the spring process and restart my server. The error cleared immediately.
I am getting the same error on Ruby 2.3.0 and rails 5.0.0.beta1:
Error: Failed to execute: ["/usr/local/rvm/gems/ruby-2.3.0/bin/wkhtmltopdf", "-q", "file:////tmp/wicked_pdf20160119-9204-xwajkb.html", "/tmp/wicked_pdf_generated_file20160119-9204-ul3rij.pdf"] Error: PDF could not be generated! Command Error
This was working on Ruby 2.1.5 and rails 4.2.0.
I have tried what suggestions here. Any ideas?
Dane,
What are you guys talking about and who are you guys?
Bob Hungry College Menus
On Tue, Jan 19, 2016 at 12:07 PM, Dane Anderson notifications@github.com wrote:
I am getting the same error on Ruby 2.3.0 and rails 5.0.0.beta1:
Error: Failed to execute: ["/usr/local/rvm/gems/ruby-2.3.0/bin/wkhtmltopdf", "-q", "file:////tmp/wicked_pdf20160119-9204-xwajkb.html", "/tmp/wicked_pdf_generated_file20160119-9204-ul3rij.pdf"] Error: PDF could not be generated! Command Error
This was working on Ruby 2.1.5 and rails 4.2.0.
I have tried what suggestions here. Any ideas?
— Reply to this email directly or view it on GitHub https://github.com/mileszs/wicked_pdf/issues/361#issuecomment-172920329.
check file permissions of wkhtmltopdf file
stopping spring and restart rails server fixed the problem for me
Possible relation? I'm not using spring on Heroku, only locally where the PDF gen works well, however the errors look similar.
@micahlisonbee I don't think they are related. They only look similar because of the specific error logging output in WickedPDF.
@mileszs agreed.
Thanks @arashm.. This solved the error for me as well: bundle exec spring binstub --all
Thanks @frahugo and @arashm bundle exec spring binstub --all
worked for me as well. Rake and rails where both and the error went away.
The tempfiles aren't getting transformed into path strings correctly:
file:////tmp/["wicked_pdf", ".html"]
What version of Ruby are you using?
I am getting errors because of temp path generated wrongly. Any help?
pdf = WickedPdf.new.pdf_from_string('<h1>Hello There!</h1>')
[wicked_pdf]: ["/home/ec2-user/.rvm/gems/ruby-2.6.0/gems/wkhtmltopdf-binary-0.12.5/bin/wkhtmltopdf", "file:////tmp/wicked_pdf20200102-10675-gzm02e.html", "/tmp/wicked_pdf_generated_file20200102-10675-1s483ea.pdf"]
Traceback (most recent call last):
1: from (irb):1
RuntimeError (Failed to execute:)
["/home/ec2-user/.rvm/gems/ruby-2.6.0/gems/wkhtmltopdf-binary-0.12.5/bin/wkhtmltopdf", "file:////tmp/wicked_pdf20200102-10675-gzm02e.html", "/tmp/wicked_pdf_generated_file20200102-10675-1s483ea.pdf"]
Error: PDF could not be generated!
Command Error: /home/ec2-user/.rvm/gems/ruby-2.6.0/gems/wkhtmltopdf-binary-0.12.5/bin/wkhtmltopdf:40:in `<main>': Invalid platform, must be running on Ubuntu 14.04/16.04/18.04 CentOS 6/7, Debian 8/9, or intel-based macOS (missing binary: /home/ec2-user/.rvm/gems/ruby-2.6.0/gems/wkhtmltopdf-binary-0.12.5/bin/wkhtmltopdf_amzn_2018.03_amd64). (RuntimeError)
Can you please guide the Solution?
@DevRor1 The message you posted contains the problem, which points to a solution.
It can't find a version of wkhtmltopdf
installed (with the binary gem) that runs on the version of linux this error is coming from (looks like Amazon).
There's a PR to that project that suggests that the CentOS 6 binary works on that platform
Do you think you could verify that fix works for you by pointing your Gemfile
at his version like this:
gem 'wkhtmltopdf-binary',
git: 'https://github.com/entretechno/wkhtmltopdf_binary_gem',
branch: 'amazon-linux'
And report back if that works for you or not?
Hi @unixmonkey, I have been following this thread as am getting the same error.
As per your last comment, I am now using wkhtmltopdf-binary
from https://github.com/entretechno/wkhtmltopdf_binary_gem and after deploying, when I tested the pdf output, I am getting:
RuntimeError: Failed to execute:
["/opt/rubies/ruby-2.6.5/bin/wkhtmltopdf", "--orientation", "Landscape", "--margin-top", "25", "--margin-bottom", "10", "--header-spacing", "3", "--header-html", "file:////tmp/wicked_header_pdf20200121-17753-1dq4e4f.html", "--footer-html", "file:////tmp/wicked_footer_pdf20200121-17753-1g9svx6.html", "file:////tmp/wicked_pdf20200121-17753-19kc290.html", "/tmp/wicked_pdf_generated_file20200121-17753-7w7n6j.pdf"]
Error: PDF could not be generated!
Command Error: /opt/rubies/ruby-2.6.5/lib/ruby/gems/2.6.0/bundler/gems/wkhtmltopdf_binary_gem-fc08925edf75/bin/wkhtmltopdf:35:in `initialize': Permission denied @ rb_sysopen - /opt/rubies/ruby-2.6.5/lib/ruby/gems/2.6.0/bundler/gems/wkhtmltopdf_binary_gem-fc08925edf75/bin/wkhtmltopdf_centos_6_amd64 (Errno::EACCES)
from /opt/rubies/ruby-2.6.5/lib/ruby/gems/2.6.0/bundler/gems/wkhtmltopdf_binary_gem-fc08925edf75/bin/wkhtmltopdf:35:in `open'
from /opt/rubies/ruby-2.6.5/lib/ruby/gems/2.6.0/bundler/gems/wkhtmltopdf_binary_gem-fc08925edf75/bin/wkhtmltopdf:35:in `<top (required)>'
from /opt/rubies/ruby-2.6.5/bin/wkhtmltopdf:23:in `load'
from /opt/rubies/ruby-2.6.5/bin/wkhtmltopdf:23:in `<main>'
The exe_path
is set as:
WickedPdf.config = {
exe_path: '/opt/rubies/ruby-2.6.5/bin/wkhtmltopdf'
}
Is this something you can help with? In my earlier Rails-5.2.3 version (running on Ruby-2.3.8), with wicked_pdf 1.4.0
and wkhtmltopdf-binary 0.12.4
with same exe_path
this was not the issue
Current Platform:
Ruby 2.6.5
Rails 6.0.2.1
Wicked PDF : gem 'wicked_pdf', github: 'mileszs/wicked_pdf', branch: 'master'
Wkhtmltopdf-binary: gem 'wkhtmltopdf-binary', git: 'https://github.com/entretechno/wkhtmltopdf_binary_gem', branch: 'amazon-linux'
kindly suggest
P.S. Since I am using a different source/version of wkhtmltopdf-binary
, I am going to test this another time by changing the exe_path
WickedPdf.config = {
exe_path: '/opt/rubies/ruby-2.6.5/bin/wkhtmltopdf-linux-amd64'
}
I will post my findings here shortly [UPDATE]: Nothing changed after changing the config to new location
I am now going to remove config/initializers/wicked_pdf.rb
and test this
OK, now I have same wicked_pdf
version, same wkhtmltopdf-binary
version (i.e. amazon-linux
, no wicked_pdf.rb
inside config/initializers and error tail is below:
RuntimeError: Failed to execute: ["/opt/rubies/ruby-2.6.5/lib/ruby/gems/2.6.0/bin/wkhtmltopdf", "--orientation", "Landscape", "--margin-top", "25", "--margin-bottom", "10", "--header-spacing", "3", "--header-html", "file:////tmp/wicked_header_pdf20200121-24488-134jtns.html", "--footer-html", "file:////tmp/wicked_footer_pdf20200121-24488-z76ze3.html", "file:////tmp/wicked_pdf20200121-24488-2izkpv.html", "/tmp/wicked_pdf_generated_file20200121-24488-baqg2f.pdf"]
Error: PDF could not be generated! Command Error: /opt/rubies/ruby-2.6.5/lib/ruby/gems/2.6.0/bundler/gems/wkhtmltopdf_binary_gem-fc08925edf75/bin/wkhtmltopdf:35:in `initialize': Permission denied @ rb_sysopen - /opt/rubies/ruby-2.6.5/lib/ruby/gems/2.6.0/bundler/gems/wkhtmltopdf_binary_gem-fc08925edf75/bin/wkhtmltopdf_centos_6_amd64 (Errno::EACCES) from /opt/rubies/ruby-2.6.5/lib/ruby/gems/2.6.0/bundler/gems/wkhtmltopdf_binary_gem-fc08925edf75/bin/wkhtmltopdf:35:in `open' from /opt/rubies/ruby-2.6.5/lib/ruby/gems/2.6.0/bundler/gems/wkhtmltopdf_binary_gem-fc08925edf75/bin/wkhtmltopdf:35:in `<top (required)>' from /opt/rubies/ruby-2.6.5/lib/ruby/gems/2.6.0/bin/wkhtmltopdf:23:in `load' from /opt/rubies/ruby-2.6.5/lib/ruby/gems/2.6.0/bin/wkhtmltopdf:23:in `<main>'
[UPDATE]: Surprisingly, when I executed this command: WickedPdf.new.pdf_from_string('<h1>Hello There!</h1>')
from my staging's web console, it worked!
And after that when I tried to see it in action from Web, the PDF generation is now happening correctly
Here's what I did (to summarise)
Using gem 'wicked_pdf', github: 'mileszs/wicked_pdf', branch: 'master'
Using gem 'wkhtmltopdf-binary', git: 'https://github.com/entretechno/wkhtmltopdf_binary_gem', branch: 'amazon-linux'
Using ruby '2.6.5'
Using gem 'rails', '~> 6.0', '>= 6.0.2.1'
Removed config/initializers/wicked_pdf.rb
I do have a question though! How amazon-linux
branch of wkhtmltopdf-binary
is different from it's base branch? And is it okay to refer this branch instead of master/base or using it directly from rubygems.org
@puneetpandey That branch has a binary specific to Amazon Linux, whereas the base branch and the released gem don't (yet anyway).
The prior version of the gem must have just worked with Amazon Linux (0.12.4 was built differently from 0.12.5).
It's fine to refer to that branch for now, but if that branch gets merged, it could get deleted. However the code would be in the main wkhtmltopdf-binary
gem. It is a little safer to fork to your own repository and point to that, in case that happens.
Alternately, you could simply pull the binary you need into your app at bin/wkhtmltopdf
and point exe_path
at that, but if you develop on a different platform, you'll likely need more than one version.
@unixmonkey Still not work for me. Please help me! Thanks
try bundle pristine
I am using wkhtmltopdf(0.10.0 rc2) and wicked_pdf(0.9.9) for generating pdf report. While running i got the following error.
my controller are:
Any help would be appreciated.
FYI:when I do :show_as_html=>true its not throwing any error.its rendering the html in browser.