简体   繁体   English

如何使R的install.packages在Dockerfile中出错?

[英]How to get R's install.packages to error out in a Dockerfile?

Below is a command that failed, but Docker kept going. 下面是一个失败的命令,但是Docker继续前进。 I'm pretty sure this is because the 'warning' ("installation had non-zero exit code") wasn't passed outward as a non-zero exit code to the Rscript invocation. 我很确定这是因为'警告'(“安装中包含非零退出代码”)没有作为非零退出代码向外传递到Rscript调用。

How can I get this to stop the Docker build? 我如何才能停止Docker构建?

Step 21/44 : RUN Rscript -e 'install.packages("https://cran.rstudio.com/src/contrib/prophet_0.1.tar.gz", dependencies=TRUE)'
 ---> Running in 26ba0c1da37c
Installing package into ‘/usr/local/spark-1.6.1-bin-hadoop2.6/R/lib’
(as ‘lib’ is unspecified)
inferring 'repos = NULL' from 'pkgs'
trying URL 'https://cran.rstudio.com/src/contrib/prophet_0.1.tar.gz'
Content type 'application/x-gzip' length 75619 bytes (73 KB)
==================================================
downloaded 73 KB

ERROR: dependencies ‘extraDistr’, ‘rstan’ are not available for package ‘prophet’
* removing ‘/usr/local/spark-1.6.1-bin-hadoop2.6/R/lib/prophet’
Warning message:
In install.packages("https://cran.rstudio.com/src/contrib/prophet_0.1.tar.gz",  :
  installation of package ‘/tmp/RtmpAa2XQV/downloaded_packages/prophet_0.1.tar.gz’ had non-zero exit status

You can force warnings to be treated as errors (ie, immediate "stop") by setting options(warn = 2) . 您可以通过设置options(warn = 2)强制将警告视为错误(即立即“停止” options(warn = 2) From ?options : ?options

 'warn': sets the handling of warning messages.  If 'warn' is
      negative all warnings are ignored.  If 'warn' is zero (the
      default) warnings are stored until the top-level function
      returns.  If 10 or fewer warnings were signalled they will be
      printed otherwise a message saying how many were signalled.
      An object called 'last.warning' is created and can be printed
      through the function 'warnings'.  If 'warn' is one, warnings
      are printed as they occur.  If 'warn' is two or larger all
      warnings are turned into errors.

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

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