通过 Docker 在 Heroku 上部署闪亮的应用程序时切换将警告视为错误

如何告诉 R 或 Docker 或 Heroku 在部署 Shiny/golem 应用时不要将警告视为错误?

我想上周我已经找到了答案 - 在我的 Dockerfile 中类似于 ENV WARNINGS_ARE_ERRORS=false 的内容 - 但我似乎无法“重新找到”它,因为我的 Google 游戏今天完全失败了; -)

一些关键资源:

这就是我的 Dockerfile 在结构上的样子

FROM rocker/r-ver:4.0.4
ENV WARNINGS_ARE_ERRORS=false
RUN apt-get update && apt-get install -y  git-core libcurl4-openssl-dev libgit2-dev libicu-dev libpq-dev libssl-dev libxml2-dev make pandoc pandoc-citeproc && rm -rf /var/lib/apt/lists/*
RUN echo "options(repos = c(CRAN = 'https://cran.rstudio.com/'),download.file.method = 'libcurl')" >> /usr/local/lib/R/etc/Rprofile.site
RUN R -e 'install.packages("remotes")'
RUN R -e 'remotes::install_github("r-lib/remotes",ref = "97bbf81")'
RUN Rscript -e 'remotes::install_version("shiny",upgrade="never",version = "1.5.0")'
RUN Rscript -e 'remotes::install_version("golem",version = "0.2.1")'

[...]

RUN Rscript -e 'remotes::install_github("rappster/confx")'
RUN mkdir /build_zone
ADD . /build_zone
WORKDIR /build_zone
RUN R -e 'remotes::install_local(upgrade="never")'
CMD R -e "options('shiny.port'=$PORT,shiny.host='0.0.0.0');mypkg::run_app()"

这是我遇到的错误的警告:

[...]

Step 25/30 : RUN Rscript -e 'remotes::install_github("rappster/confx")'
 ---> Running in f50d3dd800cb
Downloading GitHub repo rappster/confx@master
valid (NA -> 3f09feea8...) [GitHub]
Downloading GitHub repo rappster/valid@master
Running `R CMD build`...
* checking for file ‘/tmp/RtmpKWNYfH/remotes77dbc946c/rappster-valid-3f09fee/DESCRIPTION’ ... OK
* preparing ‘valid’:
* checking DESCRIPTION meta-information ... OK
* checking for LF line-endings in source and make files and shell scripts
* checking for empty or unneeded directories
* building ‘valid_0.0.0.9001.tar.gz’
Installing package into ‘/usr/local/lib/R/site-library’
(as ‘lib’ is unspecified)
* installing *source* package ‘valid’ ...
** using staged installation
** R
** byte-compile and prepare package for lazy loading
** help
*** installing help indices
** building package indices
** testing if installed package can be loaded from temporary location
** testing if installed package can be loaded from final location
** testing if installed package keeps a record of temporary installation path
* DONE (valid)
Running `R CMD build`...
* checking for file ‘/tmp/RtmpKWNYfH/remotes76bee127a/rappster-confx-e53517f/DESCRIPTION’ ... OK
* preparing ‘confx’:
* checking DESCRIPTION meta-information ... OK
* installing the package to process help pages
* checking for LF line-endings in source and make files and shell scripts
* checking for empty or unneeded directories
* building ‘confx_0.0.0.9024.tar.gz’
Installing package into ‘/usr/local/lib/R/site-library’
(as ‘lib’ is unspecified)
* installing *source* package ‘confx’ ...
** using staged installation
** R
** inst
** byte-compile and prepare package for lazy loading
Warning: replacing previous import ‘magrittr::set_names’ by ‘purrr::set_names’ when loading ‘confx’
** help
Error : (converted from warning) /tmp/RtmpqApPd2/R.INSTALL11445cdd308/confx/man/grapes-not-in-grapes.Rd: \name should not contain !,| or @
ERROR: installing Rd objects failed for package ‘confx’
* removing ‘/usr/local/lib/R/site-library/confx’
Error in i.p(...) : 
  (converted from warning) installation of package ‘/tmp/RtmpKWNYfH/file75a06ee6c/confx_0.0.0.9024.tar.gz’ had non-zero exit status
Calls: <Anonymous> ... with_rprofile_user -> with_envvar -> force -> force -> i.p
Execution halted
The command '/bin/sh -c Rscript -e 'remotes::install_github("rappster/confx")'' returned a non-zero code: 1
 ▸    Error: docker build exited with Error: 1
xinchengsoft 回答:通过 Docker 在 Heroku 上部署闪亮的应用程序时切换将警告视为错误

在一次一页地浏览我的搜索历史后,我能够再次将其拼凑起来。

原来问题是由 {remotes} 引起的,可以通过添加来解决

ENV R_REMOTES_NO_ERRORS_FROM_WARNINGS=true

到您的 Dockerfile(请参阅相关 GitHub issue

添加环境变量

R_REMOTES_NO_ERRORS_FROM_WARNINGS=TRUE

到您的 .Renviron 文件也可能有效,但尚未测试。

本文链接:https://www.f2er.com/624320.html

大家都在问