amagical-net / rails-latex

rails-latex is a renderer for rails which allows tex files with erb to be turned into an inline pdf
MIT License
141 stars 48 forks source link

error generating pdf #28

Closed jeangali closed 10 years ago

jeangali commented 11 years ago

I get this error in input.log :

can't change access mode from "rb+" to "a": /home/tim/.rvm/gems/ruby-1.9.2-p320/gems/rails-latex-1.0.11/lib/rails-latex/latex_to_pdf.rb:25:in `reopen' I fixed it by commenting lines 25 and 26 in latex_to_pdf.rb : ``` #STDOUT.reopen("input.log","a") #STDERR.reopen(STDOUT) ``` Any idea where this comes from ? All I can see is that tmp/rails-latex/input.log is missing, only tmp/rails-latex/[pid]-[hash]/input.log is generated. Thanks for your help, Jean
jacott commented 11 years ago

What OS are you running under? What happens if you change "a" to "rb+"? On 10 Jun 2013 00:01, "jeangali" notifications@github.com wrote:

I get this error in input.log :

can't change access mode from "rb+" to "a": /home/tim/.rvm/gems/ruby-1.9.2-p320/gems/rails-latex-1.0.11/lib/rails-latex/latex_to_pdf.rb:25:in `reopen'

I fixed it by commenting lines 25 and 26 in latex_to_pdf.rb :

  #STDOUT.reopen("input.log","a")
  #STDERR.reopen(STDOUT)

Any idea where this comes from ? All I can see is that tmp/rails-latex/input.log is missing, only tmp/rails-latex/[pid]-[hash]/input.log is generated.

Thanks for your help,

Jean

— Reply to this email directly or view it on GitHubhttps://github.com/jacott/rails-latex/issues/28 .

ghost commented 11 years ago

I confirm this exactly:

can't change access mode from "rb+" to "a": /srv/http/nginx/rails/ofap/shared/bundle/ruby/2.0.0/gems/rails-latex-1.0.11/lib/rails- latex/latex_to_pdf.rb:25:in `reopen' /srv/http/nginx/rails/ofap/shared/bundle/ruby/2.0.0/gems/rails-latex-1.0.11/lib/rails-latex/latex_to_pdf.rb:25:in`block in generate_pdf' /srv/http/nginx/rails/ofap/shared/bundle/ruby/2.0.0/gems/rails-latex-1.0.11/lib/rails-latex/latex_to_pdf.rb:22:in `fork' /srv/http/nginx/rails/ofap/shared/bundle/ruby/2.0.0/gems/rails-latex-1.0.11/lib/rails-latex/latex_to_pdf.rb:22:in`generate_pdf' For me, this behavior apears only in production, not in development. My OS and is the same between devel/prod: > Operating System: Parabola GNU/Linux-libre > Kernel: Linux 3.9.5-1-LIBRE > Architecture: x86_64 > ruby 2.0.0p195 (2013-05-14 revision 40734) x86_64-linux > (but that was the same with 1.9.3) > RVM isn't used > Phusion Passenger version 4.0.5 filesystem permissions are common: 644 on files and 755 on directories
jacott commented 11 years ago

On 11 Jun 2013 03:44, "Andrey Korobkov" notifications@github.com wrote:

I confirm this exactly:

can't change access mode from "rb+" to "a"

Does it work if you change the "a" to "ab" ?

topofocus commented 11 years ago

Hi, nice plugin! However, I miss the opportunity to inspect the generated latex-code directly.

I suggest the following addition to latex_to_pdf.rb:

class LatexToPdf 2 def self.config 3 @config||={:command => 'pdflatex', :arguments => ['-halt-on-error'], :parse_twice => false, :save_latex => nil } 4 end and further 20 FileUtils.mkdir_p(dir) 21 File.open(input,'wb') {|io| io.write(code) } 22 unless config[:save_latex].nil? 23 24 File.open(save_latex,'wb') {|io| io.write(code) } 25
26 end 27

In the controller I specify: LatexToPdf.config.merge! :save_latex => "/dokumente/railsoutput/main.tex"

This simply writes the latex-source to the specified file and overwrites(updates it every time. In case of errors,I find it more easy, to correct them in the source and not in the erb-file and call pdflatex manually.

greetings from Stuttgart Hartmut

jacott commented 11 years ago

If you send me a PR with tests I'll (probably) merge it.

On 12 June 2013 21:38, topofocus notifications@github.com wrote:

Hi, nice plugin! However, I miss the opportunity to inspect the generated latex-code directly.

I suggest the following addition to latex_to_pdf.rb:

class LatexToPdf 2 def self.config 3 @config https://github.com/config||={:command => 'pdflatex', :arguments => ['-halt-on-error'], :parse_twice => false, :save_latex => nil } 4 end and further 20 FileUtils.mkdir_p(dir) 21 File.open(input,'wb') {|io| io.write(code) } 22 unless config[:save_latex].nil? 23 24 File.open(save_latex,'wb') {|io| io.write(code) } 25

26 end 27

In the controller I specify: LatexToPdf.config.merge! :save_latex => "/dokumente/railsoutput/main.tex"

This simply writes the latex-source to the specified file and overwrites(updates it every time. In case of errors,I find it more easy, to correct them in the source and not in the erb-file and call pdflatex manually.

greetings from Stuttgart Hartmut

— Reply to this email directly or view it on GitHubhttps://github.com/jacott/rails-latex/issues/28#issuecomment-19315410 .

ghost commented 11 years ago

With "ab" it's the same: <STDOUT> can't change access mode from "rb+" to "ab"

What else could I try to fix it?

jacott commented 11 years ago

On 18 Jun 2013 03:14, "Andrey Korobkov" notifications@github.com wrote:

With "ab" it's the same:

can't change access mode from "rb+" to "ab" What else could I try to fix it?

Try "rb+". You may be able to leave the argument out altogether too.

cernyjakub commented 11 years ago

This error occured after I upgraded to Passenger 4. Downgrading to 3 fixes it!

I found on the net that Passenger 4 uses STDOUT for internal purposes and doesn't like if you touch it. It even does some forcibly redirect of stdout to stderr, so probabnly that is the reason why it breaks here...

Jakub

agnessa commented 11 years ago

Just for the record, I'm seeing the same thing. Changing the argument to "rb+" or leaving it out is not helping.

jacott commented 11 years ago

This appears to be a problem with Passenger 4+

I am not actively maintaining this gem any more but if someone sends me a PR fix I will publish it.

Otherwise please raise the issue with the passenger team.

brodock commented 10 years ago

+1

cernyjakub commented 10 years ago

passenger has a related issue - see https://code.google.com/p/phusion-passenger/issues/detail?id=912

but there is no visible activity over there ;(