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

Add ` "_R_CHECK_PACKAGES_USED_IGNORE_UNUSED_IMPORTS_" = "false" ` to `check(cran = TRUE)` #2459

Closed jennybc closed 1 year ago

jennybc commented 1 year ago

Result of our discussions of https://github.com/hadley/r-pkgs/issues/828

We think this NOTE should surface with check(cran = TRUE):

* checking dependencies in R code ... NOTE
Namespace in Imports field not imported from: ‘pkgA’
  All declared Imports should be used.

In R 4.1 and earlier, R CMD check --as-cran seems to actively result in _R_CHECK_PACKAGES_USED_IGNORE_UNUSED_IMPORTS_ being set to true (unused imports are ignored), which seems a bit perverse. In that case, it would be fiddly for us to make check(cran = TRUE) surface this NOTE.

However as of R 4.2, the env var seems to be settable in combination with --as-cran, so we should probably set it and just accept that the desired outcome will only happen as folks update R.