[英]How to get R's install.packages to error out in a Dockerfile?
下面是一个失败的命令,但是Docker继续前进。 我很确定这是因为'警告'(“安装中包含非零退出代码”)没有作为非零退出代码向外传递到Rscript调用。
我如何才能停止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
您可以通过设置options(warn = 2)
强制将警告视为错误(即立即“停止” options(warn = 2)
。 从?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.