I am rendering an Rmarkdown pdf in docker. In the markdown file I have two packages, lavaan
and semPlot
that are called with the library()
function. I am using the following Dockerfile:
FROM rocker/r-ver:4.2.2
RUN Rscript -e "install.packages('lavaan')"
RUN Rscript -e "install.packages('semPlot')"
RUN apt-get update \
&& apt-get install -y --no-install-recommends \
wget \
graphviz \
texlive-latex-extra \
lmodern \
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')"
When I run docker build . -t analysis
, lavaan
loads properly however I get the error:
=> ERROR [7/7] RUN Rscript -e "rmarkdown::render('Paper.Rmd')" 3.9s
------
> [7/7] RUN Rscript -e "rmarkdown::render('Paper.Rmd')":
#10 2.470
#10 2.470
#10 2.470 processing file: Paper.Rmd
|.......................................... | 80% (unnamed-chunk-1)Quitting from lines 18-28 (Paper.Rmd)
#10 3.781 Error in library(semPlot) : there is no package called 'semPlot'
#10 3.781 Calls: <Anonymous> ... withVisible -> eval_with_user_handlers -> eval -> eval -> library
#10 3.784 Execution halted
------
executor failed running [/bin/sh -c Rscript -e "rmarkdown::render('Paper.Rmd')"]: exit code: 1
I have tried solutions from: Can't install R package in docker image (added a repos argument) and semPlot package dependency issues (added installs to the Dockerfile)
Any help is appreciated, please let me know if additional information is needed. I am on a Mac with Linux.