Roxygen2: devtools::document() errors before NAMESPACE can be updated

Created on 29 May 2020  ·  5Comments  ·  Source: r-lib/roxygen2

When running devtools::document() using roxygen2 to manage the namespace, the function errors before the NAMESPACE file can be updated/written.

I have run into this in two situations:

(1) adding a new import; e.g. trying to add the S4Vectors::setValidity2 function using #' @importFrom S4Vectors setvalidity2:

devtools::document()
# Updating badInstall documentation
# Loading badInstall
# Error in setValidity2(Class = "TestClass", method = .TestClass.validity) 
# (from methods-TestClass.R#12) : 
#   could not find function "setValidity2"

(2) renaming a generic method:

devtools::document()
# Updating badInstall documentation
# Loading badInstall
# Error in add_classes_to_exports(ns = nsenv, package = package, exports = exports,  : 
#   in ‘badInstall’ methods for export not found: myOldGeneric
#   In addition: Warning message:
#   In setup_ns_exports(path, export_all, export_imports) :
#     Objects listed as exports, but not present in namespace: myOldGeneric

I am using RStudio: v1.3.959

sessionInfo()
# R version 4.0.0 (2020-04-24)
# Platform: x86_64-apple-darwin17.0 (64-bit)
# Running under: macOS Catalina 10.15.4
# 
# Matrix products: default
# BLAS:   /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libBLAS.dylib
# LAPACK: /Library/Frameworks/R.framework/Versions/4.0/Resources/lib/libRlapack.dylib
# 
# locale:
# [1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8
# 
# attached base packages:
# [1] stats     graphics  grDevices utils     datasets  methods   base     
# 
# loaded via a namespace (and not attached):
#  [1] Rcpp_1.0.4.6        compiler_4.0.0      prettyunits_1.1.1  
#  [4] remotes_2.1.1       tools_4.0.0         testthat_2.3.2     
#  [7] digest_0.6.25       pkgbuild_1.0.8      pkgload_1.0.2      
# [10] memoise_1.1.0       rlang_0.4.6         cli_2.0.2          
# [13] rstudioapi_0.11     parallel_4.0.0      xfun_0.14          
# [16] withr_2.2.0         stringr_1.4.0       roxygen2_7.1.0     
# [19] knitr_1.28          xml2_1.3.2          desc_1.2.0         
# [22] S4Vectors_0.26.1    fs_1.4.1            devtools_2.3.0     
# [25] stats4_4.0.0        rprojroot_1.3-2     glue_1.4.1         
# [28] R6_2.4.1            processx_3.4.2      fansi_0.4.1        
# [31] sessioninfo_1.1.1   callr_3.4.3         purrr_0.3.4        
# [34] magrittr_1.5        backports_1.1.7     ps_1.3.3           
# [37] ellipsis_0.3.1      BiocGenerics_0.34.0 usethis_1.6.1      
# [40] assertthat_0.2.1    stringi_1.4.6       crayon_1.3.4
bug namespace

All 5 comments

If it's helpful, I threw up this repository: https://github.com/daynefiler/badInstall.

@jimhester any insight here?

This is a roxygen2 issue so I've moved it there.

A workaround is to delete the NAMESPACE file. It will be rebuilt without an error.

Yeah, we don't have a good automated solution for this — as @adolgert suggests, your best bet is just to delete the NAMESPACE and start from scratch. I'll leave this open since there might be something we can do in pkgload, I just need to think about it a bit more.

Was this page helpful?
0 / 5 - 0 ratings