Debugging rails-latex gem on Heroku | ActionView::Template::Error rails-latex failed

核能气质少年 提交于 2021-01-29 06:39:21

问题


Problem:

I have a Rails app which generates a pdf via the rails-latex gem. It works just fine on rails s and heroku local. However, trying to use the pdf-generation-link on Heroku throws me We're sorry, but something went wrong.

Using heroku logs --tail yields me:

Rendered sheets/show.pdf.erb within layouts/application (3.4ms)
Running 'pdflatex -halt-on-error -shell-escape -interaction=batchmode input' in /app/tmp/rails-latex/4--3678030941334020140 1 times...
Completed 500 Internal Server Error in 59ms (ActiveRecord: 5.6ms)
ActionView::Template::Error (rails-latex failed: See /app/tmp/rails-latex/4--3678030941334020140/input.log for details):
19:
20: \end{document}
app/views/layouts/application.pdf.erbtex:22:in `_app_views_layouts_application_pdf_erbtex___[LOTS OF NUMBERS]

Again, the rest of the Heroku app and the local version are working, so this is not a problem with models etc.

teX is installed with a buildback (the installation shows as successful when pushing). heroku buildpacks is:

1. heroku/ruby
2. https://github.com/Thermondo/heroku-buildpack-tex.git

What I tried:

I tried to access the file referenced in the error message, however (I think because of Herokus dyno system) the app/tmp does not exist or isn't accessible by the heroku run bash console at least.

The layout file referenced in the logs contains:

\documentclass[12pt,a5paper,sloppy]{article}
<% @latex_config = { :recipe => [
	{:command => 'pdflatex'},
]} # you can override the defaults if you wish; see LatexToPdf#config
%>
\usepackage{filecontents}
\usepackage{lastpage}
\usepackage{graphics}
\usepackage[utf8]{inputenc}
\usepackage{scrextend}
\usepackage[a5paper, left=.3cm, right=.3cm, bottom=0cm, top=0.3cm]{geometry}

\setlength\parindent{0pt}
\thispagestyle{empty}

\begin{document}

	<%= yield %>

\end{document}

Conclusion:

I'm really at a loss here because I can't get more information to debug nor replicate the error anywhere else.


回答1:


Just in case anyone ever stumbles upon this:

After a lot of headache I found that my file containing my tex packages (instructed in the README of the buildpack) was incorrectly named and not doing anything, so I was trying to use non-existing packages.

Fixing that sent me down another rabbithole in the world of texlive-versions, but brute-forcing my way through various version declaration and replacing libraries finally got me a working Heroku app.

If you have a similar problem, I recommend deleting all tex dependencies, get a MWE and then slowly add them back in to identify the evildoers.



来源:https://stackoverflow.com/questions/54789173/debugging-rails-latex-gem-on-heroku-actionviewtemplateerror-rails-latex-fa

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!