【问题标题】:R Shiny Golem Dockerfile not buildable - there is no package called ‘remotes’R Shiny Golem Dockerfile 不可构建 - 没有名为“remotes”的包
【发布时间】:2021-12-29 09:38:07
【问题描述】:

我正在为 Shiny App 开发一个 R 包并使用 Docker 将其容器化,并且我使用 Golem 的 add_dockerfile() 命令在下面创建了 Dockerfile。 (为简洁起见,我删除了大部分依赖项。)不幸的是,它没有构建。请问有人可以帮忙吗?

Dockerfile

FROM rocker/r-ver:4.1.1
RUN apt-get update && apt-get install -y  git-core libcurl4-openssl-dev libgit2-dev libicu-dev libssl-dev libxml2-dev make pandoc pandoc-citeproc unixodbc-dev && rm -rf /var/lib/apt/lists/*
  RUN echo "options(repos = c(CRAN = 'http://cran.rstudio.com/'), download.file.method = 'libcurl', Ncpus = 4)" >> /usr/local/lib/R/etc/Rprofile.site
RUN R -e 'install.packages("remotes")'
RUN Rscript -e 'remotes::install_version("rlang",upgrade="never", version = "0.4.11")'
RUN Rscript -e 'remotes::install_version("glue",upgrade="never", version = "1.4.2")'

RUN mkdir /build_zone
ADD . /build_zone
WORKDIR /build_zone
RUN R -e 'remotes::install_local(upgrade="never")'
RUN rm -rf /build_zone
EXPOSE 3838
CMD R -e "options('shiny.port' = 3838,shiny.host='0.0.0.0');exampleApp::run_app()"

错误信息

当我尝试使用 docker build -t "test_image" . 构建它时,我收到以下错误消息:

=> ERROR [45/46] RUN R -e 'remotes::install_local(upgrade="never")'                                                                                        17.1s 
------
 > [45/46] RUN R -e 'remotes::install_local(upgrade="never")':
#49 0.499
#49 0.499 R version 4.1.1 (2021-08-10) -- "Kick Things"
#49 0.499 Copyright (C) 2021 The R Foundation for Statistical Computing
#49 0.499 Platform: x86_64-pc-linux-gnu (64-bit)
#49 0.499
#49 0.499 R is free software and comes with ABSOLUTELY NO WARRANTY.
#49 0.499 You are welcome to redistribute it under certain conditions.
#49 0.499 Type 'license()' or 'licence()' for distribution details.
#49 0.499
#49 0.499 R is a collaborative project with many contributors.
#49 0.499 Type 'contributors()' for more information and
#49 0.499 'citation()' on how to cite R or R packages in publications.
#49 0.499
#49 0.499 Type 'demo()' for some demos, 'help()' for on-line help, or
#49 0.499 'help.start()' for an HTML browser interface to help.
#49 0.499 Type 'q()' to quit R.
#49 0.499
#49 0.614 # Bootstrapping renv 0.14.0 --------------------------------------------------
#49 2.171 * Downloading renv 0.14.0 ... OK (downloaded source)
#49 3.624 * Installing renv 0.14.0 ... Done!
#49 16.84 * Successfully installed and loaded renv 0.14.0.
#49 16.97 * Project '/build_zone' loaded. [renv 0.14.0]
#49 17.03 > remotes::install_local(upgrade="never")
#49 17.04 Error in loadNamespace(x) : there is no package called ‘remotes’
#49 17.04 Calls: loadNamespace -> withRestarts -> withOneRestart -> doWithOneRestart
#49 17.04 Execution halted

所以看起来在工作目录移动到 /build_zone 后找不到 remotes 包。谁能解释为什么会发生这种情况?我尝试了一种解决方法,并且设法构建了映像,但是当我尝试运行它时,它说我的包 (exampleApp) 也没有找到。我对 Docker 命令的理解不够深入,无法知道发生了什么。

谢谢!

【问题讨论】:

  • 您好,这是因为您正在使用 {renv} 进行开发。 {remotes} 需要在您的 renv.lock 文件中列出,以便在您恢复内容时可用。无论之前安装了什么软件包,{renv} 都可以确保一个封闭的环境。你可以看看这个问题,不是所有的都解决了,但差不多:github.com/ThinkR-open/golem/issues/282
  • 非常感谢!我已经在 renv.lock 文件中有 {remotes},但是你提供的链接有我需要的。对我来说,这是将 renv/ 和 .Rprofile 添加到 .dockerignore 文件中——这是我自己永远想不到的。

标签: r docker shiny package golem


【解决方案1】:

当您使用{renv} 时,您需要在renv.lock 和/或{renv} 库中包含{remotes} 才能在build_zone 中执行remotes::install_local(upgrade="never")

如果你不想在你的开发环境中使用它,你可以这样做:

RUN R -e 'renv::install("remotes");remotes::install_local(upgrade="never")'

干杯,

科林

【讨论】:

    猜你喜欢
    • 2018-04-09
    • 2021-05-14
    • 2022-07-14
    • 2021-10-15
    • 2015-05-01
    • 1970-01-01
    • 2023-02-07
    • 2021-11-02
    • 1970-01-01
    相关资源
    最近更新 更多