Skip to content

feat(dock_from_desc): add strict_install parameter (default TRUE)#105

Merged
VincentGuyader merged 1 commit intomasterfrom
feat/strict-install-9
May 6, 2026
Merged

feat(dock_from_desc): add strict_install parameter (default TRUE)#105
VincentGuyader merged 1 commit intomasterfrom
feat/strict-install-9

Conversation

@VincentGuyader
Copy link
Copy Markdown
Member

Summary

Closes #9.

R -e 'remotes::install_*(...)' lets the docker build succeed even
when an install emitted a warning that silently masked a real
failure: "package was archived from CRAN", "partial download,
retrying", "no installation candidate". The docker user only finds
out the package is missing at container runtime.

Add a new strict_install parameter, default TRUE. When TRUE,
every install RUN is prefixed with options(warn = 2); so any R
warning during install becomes a hard error and aborts the build.
The opt-out (strict_install = FALSE) restores the previous
tolerant behaviour for build environments that emit benign
warnings (locale defaulting, NTP time-verification, ABI-version
notices) the caller does not want to fail the build.

Behaviour change

This is a behaviour change for users regenerating their Dockerfile.
Each install RUN now emits

RUN R -e 'options(warn = 2); install.packages(...)'
RUN Rscript -e 'options(warn = 2); remotes::install_version(...)'

instead of the bare form. To restore the previous behaviour:

dock_from_desc("DESCRIPTION", strict_install = FALSE)

Scope

The injection covers the five install RUN sites in
dock_from_desc():

  • R -e 'install.packages("remotes")'
  • Rscript -e 'remotes::install_version(...)' per CRAN dep
  • Rscript -e 'remotes::install_github(...)' per non-CRAN dep
  • R -e 'remotes::install_local("/app.tar.gz")' (build_from_source = FALSE)
  • R -e 'remotes::install_local()' (build_from_source = TRUE)

dock_from_renv() is not covered by this PR; it has its own
install RUN family (renv::restore(), install.packages("renv"),
install_version("renv", ...)) and a follow-up will extend the
same options(warn = 2); injection there.

Test plan

  • TDD red-first: signature test, behaviour test for both modes,
    backward-compat-default test.
  • devtools::test(filter = "dock_from_desc") -> [ FAIL 0 | PASS 69 ].
  • R CMD check pending (will be confirmed by CI on this branch).
  • NEWS bullet under ## New features documents the behaviour
    change and the opt-out.

Context

Tier A item from the post-CRAN-prep roadmap (the local prep report
at /home/ubuntu/thinkr-work/dockerfiler-cran-0.3.0-prep.md for
the full audit). Companion follow-up is the user + renv_paths_cache
out-of-box fix in another PR (#100).

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR introduces a new strict_install parameter to dock_from_desc() to make Docker image builds fail fast when R package installation emits warnings (by prepending options(warn = 2); to install RUN commands), addressing missing/archived/unavailable packages that would otherwise only surface at runtime.

Changes:

  • Add strict_install argument (default TRUE) to dock_from_desc() and inject options(warn = 2); into all generated install RUN commands.
  • Add an internal helper .r_strict_prefix() to centralize the strict-install prefix logic.
  • Add tests for strict vs non-strict behavior and document the behavior change in NEWS + generated Rd.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
R/dock_from_desc.R Adds strict_install parameter and applies strict warning-to-error prefix across install RUN lines.
R/utils.R Introduces .r_strict_prefix() helper used by Dockerfile generation.
tests/testthat/test-dock_from_desc.R Adds coverage for strict/non-strict modes and asserts default is strict.
NEWS.md Documents new strict_install feature and behavior change (default strict).
man/dockerfiles.Rd Updates generated documentation to include strict_install parameter.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread R/dock_from_desc.R
Comment on lines 265 to 272
pong <- mapply(
function(dock, ver, nm) {
function(dock, ver, nm, strict_prefix) {
res <- dock$RUN(
sprintf(
"%sRscript -e 'remotes::install_github(\"%s\")'",
"%sRscript -e '%sremotes::install_github(\"%s\")'",
.github_pat_run_prefix(github_pat),
strict_prefix,
ver
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 5 out of 5 changed files in this pull request and generated 3 comments.

Comment thread R/utils.R
Comment on lines +84 to +89
.r_strict_prefix <- function(strict_install) {
if (isTRUE(strict_install)) {
"options(warn = 2); "
} else {
""
}
Comment thread tests/testthat/test-dock_from_desc.R Outdated

test_that("dock_from_desc(strict_install = TRUE) prepends options(warn = 2) to every install RUN", {
skip_if(is_rdevel, "skip on R-devel")
skip_on_os("mac")
Comment thread tests/testthat/test-dock_from_desc.R Outdated

test_that("dock_from_desc(strict_install = FALSE) does not prepend options(warn = 2)", {
skip_if(is_rdevel, "skip on R-devel")
skip_on_os("mac")
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 5 out of 5 changed files in this pull request and generated no new comments.

Closes #9.

The previous behaviour of `R -e 'remotes::install_*(...)'` lets a
docker build succeed even when an install emitted a warning that
silently masked a real failure: "package was archived from CRAN",
"partial download, retrying", "no installation candidate". The
docker user only finds out the package is missing at container
runtime.

Add a new `strict_install` parameter, default `TRUE`. When `TRUE`,
every install RUN is prefixed with `options(warn = 2);` so any R
warning during install becomes a hard error and aborts the build.
The opt-out (`strict_install = FALSE`) restores the previous
tolerant behaviour for build environments that emit benign
warnings (locale defaulting, NTP time-verification, ABI-version
notices) the caller does not want to fail the build.

The injection covers the five install RUN sites in
`dock_from_desc()`:
- `R -e 'install.packages("remotes")'`
- `Rscript -e 'remotes::install_version(...)'` per CRAN dep
- `Rscript -e 'remotes::install_github(...)'` per non-CRAN dep
- `R -e 'remotes::install_local("/app.tar.gz")'` (build_from_source = FALSE)
- `R -e 'remotes::install_local()'` (build_from_source = TRUE)

`dock_from_renv()` is not covered by this PR; it has its own
install RUN family (`renv::restore()`, `install.packages("renv")`,
`install_version("renv", ...)`) and a separate POC will extend
the same `options(warn = 2);` injection there.

R CMD check --as-cran: 0 errors / 0 warnings / 0 notes.
@VincentGuyader VincentGuyader force-pushed the feat/strict-install-9 branch from 21171f4 to c658211 Compare May 6, 2026 08:10
@VincentGuyader VincentGuyader merged commit 1f6375d into master May 6, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add options(warn = 2) to Dockerfile

2 participants