/ / Rのinstall.packagesをDockerfileでエラーにする方法は? - r

Rのinstall.packagesをDockerfileでエラーにする方法は? - r

以下は失敗したコマンドですが、Dockerは行く。これは、 "警告"( "インストールにゼロ以外の終了コードがある")がRscript呼び出しに0以外の終了コードとして外側に渡されなかったためです。

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

回答:

回答№1は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.