gpt4 book ai didi

r - 在 docker 上安装本地 R 库时遇到问题

转载 作者:行者123 更新时间:2023-12-04 17:23:00 24 4
gpt4 key购买 nike

我正在尝试在 docker 上部署我的 Shiny 应用程序(使用 Rocker/shiny-verse:3.6.3 基础镜像),但是当我尝试通过 docker 安装本地(非 CRAN)软件包时遇到了问题。在 RStudio 中完成安装后,安装工作正常。

  • Docker 引擎 v19.03.13
  • 操作系统:Windows 10 企业版

  • 成功 - 当我尝试在 RStudio 中安装本地包时:
    > install.packages("<FULLPATH>/customLibrary.zip", repos = NULL, type = "win.binary")
    WARNING: Rtools is required to build R packages but is not currently installed. Please download and install the appropriate version of Rtools before proceeding:

    https://cran.rstudio.com/bin/windows/Rtools/
    Installing package into ‘C:/Users/p/Documents/R/win-library/3.6’
    (as ‘lib’ is unspecified)
    package ‘customLibrary’ successfully unpacked and MD5 sums checked

    文件
    FROM rocker/shiny-verse:3.6.3
    RUN R -e "install.packages('<FULLPATH>/customLibrary.zip', repos = NULL, type = 'win.binary')"
    RUN R -e "install.packages(c('gtable', 'data.table', 'shinydashboard', 'ggplot2'), repos='https://cran.rstudio.com', dependencies=FALSE)"
    COPY . /srv/shiny-server
    EXPOSE 3838
    失败 - 当我使用上述 Dockerfile 构建我的 Docker 镜像时:
    [+] Building 0.8s (6/8)
    => [internal] load build definition from Dockerfile 0.1s
    => => transferring dockerfile: 465B 0.0s
    => [internal] load .dockerignore 0.1s
    => => transferring context: 2B 0.0s
    => [internal] load metadata for docker.io/rocker/shiny-verse:3.6.3 0.0s
    => CACHED [1/4] FROM docker.io/rocker/shiny-verse:3.6.3 0.0s
    => [internal] load build context 0.0s
    => => transferring context: 517B 0.0s
    => ERROR [2/4] RUN R -e "install.packages('<FULLPATH>/customRLibrary.zip', repos = NULL, type = 'win.bin 0.7s
    ------
    > [2/4] RUN R -e "install.packages('<FULLPATH>/customRLibrary.zip', repos = NULL, type = 'win.binary')":
    #5 0.599
    #5 0.599 R version 3.6.3 (2020-02-29) -- "Holding the Windsock"
    #5 0.599 Copyright (C) 2020 The R Foundation for Statistical Computing
    #5 0.599 Platform: x86_64-pc-linux-gnu (64-bit)
    #5 0.599
    #5 0.599 R is free software and comes with ABSOLUTELY NO WARRANTY.
    #5 0.599 You are welcome to redistribute it under certain conditions.
    #5 0.599 Type 'license()' or 'licence()' for distribution details.
    #5 0.599
    #5 0.599 R is a collaborative project with many contributors.
    #5 0.599 Type 'contributors()' for more information and
    #5 0.599 'citation()' on how to cite R or R packages in publications.
    #5 0.599
    #5 0.599 Type 'demo()' for some demos, 'help()' for on-line help, or
    #5 0.599 'help.start()' for an HTML browser interface to help.
    #5 0.599 Type 'q()' to quit R.
    #5 0.599
    #5 0.723 > install.packages('<FULLPATH>/customRLibrary.zip', repos = NULL, type = 'win.binary')
    #5 0.728 Installing package into ‘/usr/local/lib/R/site-library’
    #5 0.728 (as ‘lib’ is unspecified)
    #5 0.728 Error in install.packages("<FULLPATH>/customRLibrary.zip", :
    #5 0.728 cannot install Windows binary packages on this platform
    #5 0.728 Execution halted
    ------
    failed to solve with frontend dockerfile.v0: failed to build LLB: executor failed running [/bin/sh -c R -e "install.packages('<FULLPATH>/customRLibrary.zip', repos = NULL, type = 'win.binary')"]: runc did not terminate sucessfully

    有人能指出我哪里出错了吗? TIA。

    最佳答案

    在 RStudio 中,你开发你的包,安装 devtools 然后运行

    devtools::build(binary = FALSE)
    它将生成一个可以安装在任何平台上的 tar.gz 包。
    这是文档: https://rdrr.io/cran/devtools/man/build.html

    关于r - 在 docker 上安装本地 R 库时遇到问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/65031741/

    24 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com