简体   繁体   English

R docker 容器中没有调用 package

[英]R there is no package called in a docker container

I have a docker image where I install several packages using the following lines:我有一个 docker 图像,我使用以下几行安装了几个包:

FROM rocker/verse:4.0.3
... (some other installation details)
RUN install2.r --error \
    glmnet \
    ineq
    ...

However, I sporadically get error messages when running a container from that image where it seems like R cannot find that package:但是,从该图像运行容器时,我偶尔会收到错误消息,其中 R 似乎找不到 package:

Error in library(ineq) : there is no package called 'ineq'

If I create a new version of the container and manually open R and run it, I can never reproduce this error.如果我创建一个新版本的容器并手动打开 R 并运行它,我将永远无法重现此错误。 Does anyone have any idea of how I can fix this (or what I should be looking for to reproduce this)?有谁知道我该如何解决这个问题(或者我应该寻找什么来重现这个问题)?

Hitting the same "weird" behaviour..击中相同的“奇怪”行为..

My workaround was (I know its not elegant) using pacman instead of the library lines.我的解决方法是(我知道它不优雅)使用 pacman 而不是库行。 What pacman does if it can't find the library it simply installs it.如果 pacman 找不到库,它会做什么,它只是安装它。 Which is obviously rude and anti-container pattern but at some point we need to move on:-/.. A big disadvantage here is that the container startup time could be huge if it is lost all of its packages and starts to re-install them这显然是粗鲁和反容器模式,但在某些时候我们需要继续:-/.. 这里的一个很大的缺点是,如果容器丢失所有包并开始重新安装,则容器启动时间可能会很长他们

if(!require("pacman")) install.packages("pacman")
pacman::p_load("glmnet","ineq")

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM