Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

check_built() changes default for 'error_on' in undocumented way #2506

Closed
kenahoo opened this issue Mar 13, 2023 · 1 comment · Fixed by #2541
Closed

check_built() changes default for 'error_on' in undocumented way #2506

kenahoo opened this issue Mar 13, 2023 · 1 comment · Fixed by #2541

Comments

@kenahoo
Copy link

kenahoo commented Mar 13, 2023

In our build process, I recently replaced some code that shelled out to R CMD check with devtools::check_built(). Errors started happening, but I couldn't reproduce them when I fired up RStudio and did check_built() from there.

It turns out that check_built() is modifying the default for its error_on argument in an undocumented way - if the build is happening in a non-interactive session, it defaults to "error", otherwise it acts as documented (defaults to "never").

The current docs (version 2.4.5):

error_on

Whether to throw an error on ⁠R CMD check⁠ failures. Note that the check is always completed
(unless a timeout happens), and the error is only thrown after completion. If "never", then 
no errors are thrown. If "error", then only ERROR failures generate errors. If "warning", then 
WARNING failures generate errors as well. If "note", then any check failure generated an error. 
Its default can be modified with the RCMDCHECK_ERROR_ON environment variable. If that is 
not set, then "never" is used.

The current code:

> devtools::check_built
function (path = NULL, cran = TRUE, remote = FALSE, incoming = remote, 
    force_suggests = FALSE, run_dont_test = FALSE, manual = FALSE, 
    args = "--timings", env_vars = NULL, check_dir = tempdir(), 
    quiet = FALSE, error_on = c("never", "error", "warning", 
        "note")) 
{
    if (missing(error_on) && !interactive()) {
        error_on <- "warning"
    }

It's probably also worth mentioning that RCMDCHECK_ERROR_ON doesn't seem to be consulted either?

My inclination for a fix would be to change the code rather than the docs (for error_on - I have no opinion on RCMDCHECK_ERROR_ON), because it can be mysterious when a pipeline does one thing while interactive code does another.

@jennybc
Copy link
Member

jennybc commented Nov 2, 2023

The confusion arises from the fact that devtools inherits the documentation of error_on from rcmdcheck::rcmdcheck().

The most practical fix is to change the devtools docs.

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 a pull request may close this issue.

2 participants