Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7615915
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T02:45:38+00:00 2026-05-31T02:45:38+00:00

So I have a Rails application that upon user submission should generate some kind

  • 0

So I have a Rails application that upon user submission should generate some kind of a .tex file based on the user input, compile it into a pdf, and deliver the pdf. Through process of elimination, I am pretty positive that everything is working except for one line; the one where pdflatex is called.

Here’s the vital snippet of code:
(If it matters, its located in the Questions controller under the generate action, which is called after the form sends the relevant information. Though this may not be the best way, I’m pretty certain its not the cause of the error)

texHeader = 'app\assets\tex\QuestionsFront.txt' 
texOut = 'app\assets\tex\Questions.tex'

#copy latex header to new file
FileUtils.cp(texHeader, texOut)

File.open(texOut, 'a+') do |fout|
      fout.write("\n")
         # a loop writes some more code to fout (its quite lengthy)
      fout.write("\\end{enumerate}\n")
      fout.write("\\end{document}")
      #The problem line:
      puts `pdflatex app/assets/tex/Questions.tex --output-directory=app/assets/tex`
    end

    filename = 'Questions.pdf'
    filelocation = "app\\assets\\tex\\" + filename

    File.open(filelocation, 'r') do |file|
      send_file file, :filename => filename, :type => "application/pdf", :disposition => "attachment"
    end
end

Here’s my reasoning: It generates the .tex file correctly, and given a pre-created Questions.pdf file it sends it just fine. When the command in the puts is copied to the terminal, it runs without a hitch (the file begins with \nonstopmode so no worries about small errors). But for some reason, when I run the above script, not even a log file is created with an error.

What am I overlooking? Any ideas? Any way of seeing what output the puts line is creating?

Thanks so much in advance!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T02:45:39+00:00Added an answer on May 31, 2026 at 2:45 am

    Figured out my own problem. The error is pretty interesting. You’ll see I’m calling

     puts `pdflatex app/assets/tex/Questions.tex --output-directory=app/assets/tex`
    

    within the block

    File.open(texOut, 'a+') do |fout|
    

    where just a few lines prior

    texOut = 'app\assets\tex\Questions.tex'
    

    Basically, I’m trying to get latex to compile a document while the file is still open. So long as I’m in the File.open block, the file is open, and its automatically closed upon the end of the block.
    Cutting and pasting the line of code down below the end of the block made it work just like I wanted. However, for the sake of clarity and the rare case where someone else has this problem, its actually better to open a separate system shell, navigate to the directory where the latex document is and do the compiling there. So, my updated code looks like:

      fout.write("\\end{document}")
    end
    
    system 'runlatex.bat'
    

    where that batch file is as follows:

    cd app/assets/tex
    pdflatex Questions.tex
    

    That way any additional files in the tex directory are found, the log file is created there, etc.

    Reason why I never got a log file? The pdflatex never executed – the OS stopped it with a permissions error before it ever ran.

    Hope this helps!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a Rails application that in the erb code, I use a select
I have a Rails application that unfortunately after a request to a controller, has
I have a rails application that about 3 years old, and I'm having a
I have a Rails application that uses ActiveRecordStore for sessions. I need a PHP
I have a Rails application that lists information about local services. My objectives for
I have a rails application that allows searches using longitude and latitude. I have
I have a rails application deployed that works fine in Safari, Firefox, and Opera.
We have a rails application in subversion that we deploy with Capistrano but have
I have created a table in my Ruby on Rails application that I am
I am thinking of working on a Rails application that uses PostgreSQL. I have

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.