On 12 February 2026 at 15:52, Bjarke Hautop wrote: | Hi all, | | R CMD check gives a false positive locally when the only usage of an | imported package is through pkg::foo() inside an R6 class. This GitHub repo | contains a full MWE, with log files and a more elaborate explanation: | https://github.com/BjarkeHautop/RCMDcheckFalsePositive | | The R package contains a single .R file with this (I'm aware you don't have | to import base packages explicitly, but this is an MWE with only base | packages (except R6)): | | filter <- function() { | message("This is a custom filter function.") | } | | DataProcessor <- R6::R6Class( | "DataProcessor", | public = list( | data = NULL, | initialize = function(data) self$data <- data, | | filter_data = function(data) { | filter() | self$data <- stats::filter(self$data, rep(1, 3)) | } | ) | ) | | When running R CMD check, it will generate the following NOTE: | | * checking dependencies in R code ... NOTE | Namespaces in Imports field not imported from: | ‘R6’ ‘stats’
Thanks for posting a full and complete example! From a quick glance your problem may be that while you DO have the the packages in DESCRIPTION you DO NOT import them in NAMESPACE. The error message could arguably be more explicit but that seems to be the case here. Hope this helps, Dirk | Interestingly, the NOTE disappears on CRAN release/dev winbuilder. | | My questions are: | | 1. Is this the intended behavior of R CMD check, or is it a bug that it | fails to detect usage of packages inside | R6 classes? If intended (e.g., due to it being too expensive to check for | :: in "hidden places") should this be | mentioned somewhere on WRE? Currently | [WRE]( | https://cran.r-project.org/doc/manuals/r-devel/R-exts.html#Package-Dependencies-1) | says: | *"The ‘Imports’ field should not contain packages which are not imported | from (via the NAMESPACE file or :: or ::: operators)"* | indicating that `::` usage should be fully supported. | | 2. How/Why does the NOTE disappear when checking on CRAN dev winbuilder? | Can I replicate this behavior locally using R CMD check? Will it pass on | CRAN? | | Best regards, | Bjarke | | [[alternative HTML version deleted]] | | ______________________________________________ | [email protected] mailing list | https://stat.ethz.ch/mailman/listinfo/r-package-devel -- dirk.eddelbuettel.com | @eddelbuettel | [email protected] ______________________________________________ [email protected] mailing list https://stat.ethz.ch/mailman/listinfo/r-package-devel
