Search code examples
dockerr-markdownpdflatex

docker rocker rmarkdown::render error pdflatex not found


I am using rocker to render an rmarkdown pdf on a Mac Version 12.6.1 with Linux.

In bash:

cd /Users/user/Documents/Docker_Project/
touch Dockerfile

Dockerfile contains:

FROM rocker/r-ver:4.2.2
RUN apt-get update \
  && apt-get install -y --no-install-recommends \
   wget \
   graphviz \
   perl && \
   /rocker_scripts/install_pandoc.sh && \
   install2.r rmarkdown
ENV RSTUDIO_PANDOC=/usr/lib/rstudio/bin/pandoc
COPY . /home/user
WORKDIR /home/user/
RUN Rscript -e "rmarkdown::render('Paper.Rmd')"

Paper.Rmd contains:

---
title: "Factor Analysis"
output: pdf_document
date: "2023-04-04"
---

```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
```

# Methods

- Sample Text

In bash:

docker build . -t analysis

Produces:

 => ERROR [7/7] RUN Rscript -e "rmarkdown::render('Paper.Rmd')"                                                                                                                                       1.9s
------                                                                                                                                                                                                     
 > [7/7] RUN Rscript -e "rmarkdown::render('Paper.Rmd')":                                                                                                                                                  
#11 0.817                                                                                                                                                                                                  
#11 0.817                                                                                                                                                                                                  
#11 0.817 processing file: Paper.Rmd                                                                                                                                                                       
                                                                                                            
#11 1.353 output file: Paper.knit.md
#11 1.353 
#11 1.358 /usr/bin/pandoc +RTS -K512m -RTS Paper.knit.md --to latex --from markdown+autolink_bare_uris+tex_math_single_backslash --output Paper.tex --lua-filter /usr/local/lib/R/site-library/rmarkdown/rmarkdown/lua/pagebreak.lua --lua-filter /usr/local/lib/R/site-library/rmarkdown/rmarkdown/lua/latex-div.lua --embed-resources --standalone --highlight-style tango --pdf-engine pdflatex --variable graphics --variable 'geometry:margin=1in' 
#11 1.850 ! sh: 1: pdflatex: not found
#11 1.850 
#11 1.850 Error: LaTeX failed to compile Paper.tex. See https://yihui.org/tinytex/r/#debugging for debugging tips. See Paper.log for more info.
#11 1.850 In addition: Warning message:
#11 1.851 In system2(..., stdout = if (use_file_stdout()) f1 else FALSE, stderr = f2) :
#11 1.851   error in running command
#11 1.852 Execution halted
------
executor failed running [/bin/sh -c Rscript -e "rmarkdown::render('Paper.Rmd')"]: exit code: 1

I have absolutely no idea what the error is and have found no resources on how to fix it. Any help is appreciated. Also very happy to reformat, clarify, or add any necessary information.


Solution

  • the solution is to install texlive-latex-extra and lmodern