如何在 heroku 中安装 pdflatex

How to install pdflatex in heroku

我使用 flask 将 markdown 转换为 pdf 转换器。转换无效,显示内部服务器错误。

为了跟踪它,我 运行 heroku logs 得到了这个错误:

2018-05-04T03:38:26.134931+00:00 app[web.1]:   File "/app/.heroku/python/lib/python3.6/site-packages/pypandoc/__init__.py", line 325, in _convert_input
2018-05-04T03:38:26.134932+00:00 app[web.1]:     'Pandoc died with exitcode "%s" during conversion: %s' % (p.returncode, stderr)
2018-05-04T03:38:26.134942+00:00 app[web.1]: RuntimeError: Pandoc died with exitcode "47" during conversion: b'pdflatex not found. Please select a different --pdf-engine or install pdflatex\n'

这是有道理的,因为我使用 pandoc 进行转换。

为了解决这个错误,我尝试寻找支持pdflatex的buildpack。不幸的是我找不到。

所以,我尝试了另一种可能的解决方案,通过 heroku run 安装 pdflatex。

gofrendi@asgard:~/Projects/markdown-to-moodle-xml$ heroku run apt-get install pdflatex
Running apt-get install pdflatex on ⬢ m2m-py... up, run.7496 (Free)
Reading package lists... Done
Building dependency tree       
Reading state information... Done
W: Not using locking for read only lock file /var/lib/dpkg/lock
E: Unable to locate package pdflatex

不过可能是我哪里弄错了。

我的问题是:如何在我的 heroku 应用程序上安装 pdflatex?

无需自定义构建包 - 您始终可以在 build - packages 指令内定义要安装在 heroku.yaml 上的包:

build:
  packages:
    - texlive-latex-base
    - texlive-fonts-recommended
    - texlive-fonts-extra
    - texlive-latex-extra