在 docker build 中找不到 R 包

问题描述 投票:0回答:0

我正在 docker 中渲染 Rmarkdown pdf。在 markdown 文件中,我有两个包,

lavaan
semPlot
,它们是用
library()
函数调用的。我正在使用以下 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')"

当我运行

docker build . -t analysis
时,
lavaan
正确加载但是我得到错误:

=> 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

我尝试过以下解决方案: 无法在 docker 镜像中安装 R 包(添加了一个 repos 参数)和 semPlot 包依赖问题(添加安装到 Dockerfile)

感谢任何帮助,如果需要其他信息,请告诉我。我在装有 Linux 的 Mac 上。

r docker r-package semplot
© www.soinside.com 2019 - 2024. All rights reserved.