r-lib / devtools

Tools to make an R developer's life easier
https://devtools.r-lib.org
Other
2.37k stars 755 forks source link

`document(quiet = TRUE)` is too quiet when a required package is not installed #2532

Open haugedal opened 10 months ago

haugedal commented 10 months ago

When running document() with the argument quiet = TRUE on a package where another required package is not installed you get the following “question”:

Selection:

With no information about what you are answering/selecting or how to answer/select.

The unsuppressed question with selections is as follows:

ℹ The package "packageName" is required.
✖ Would you like to install it?

1: Yes
2: No

It seems reasonable to show this information when running document(), even with quiet = TRUE.

jennybc commented 8 months ago

I agree it is reasonable to surface this, but this is also relatively low priority. I think an attempt to do any other package development task will likely also surface this problem in a less cryptic way.

I see this in roxygen2::roxygenize():

https://github.com/r-lib/roxygen2/blob/066c3a504ef94e9fcdf3a133706e59e184dfaa27/R/roxygenize.R#L53-L55

if (!is_interactive()) {
    withr::local_options(warn = 1)
}

So the easiest fix would be to call roxygen2::roxygenize() as if non-interactive when quiet = TRUE to get whatever the intended experience is in a non-interactive session.