首页 > 解决方案 > R CMD 检查,警告,Rd 交叉引用,没有可用的包

问题描述

我正在对我的包裹运行 R CMD 检查。我的命令如下:

R CMD check --no-vignettes --no-manual --ignore-vignettes \path\to\package

检查 Rd 交叉引用时,我收到以下警告:

checking Rd cross-references ... WARNING Error in find.package(package, lib.loc) : there is no package called 'cluster' Calls: <Anonymous> -> lapply -> FUN -> find.package Execution halted

问题是我不在代码中使用cluster包。DESCRIPTION它未在文件中列为依赖项。cluster在 /R 和 /man 中没有引用。

可能会发生什么?

PS附加信息:

> sessionInfo()
R version 3.5.3 (2019-03-11)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows Server x64 (build 14393)

Matrix products: default

locale:
[1] LC_COLLATE=English_United States.1252  LC_CTYPE=English_United States.1252    LC_MONETARY=English_United States.1252
[4] LC_NUMERIC=C                           LC_TIME=English_United States.1252    

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] my_package_1.0.0   testthat_2.1.1

loaded via a namespace (and not attached):
 [1] Rcpp_1.0.1                 lubridate_1.7.4            prettyunits_1.0.2          assertive.properties_0.0-4
 [5] assertive.types_0.0-3      assertive.data.us_0.0-2    ps_1.3.0                   assertthat_0.2.1          
 [9] zeallot_0.1.0              rprojroot_1.3-2            digest_0.6.20              foreach_1.4.4             
[13] R6_2.4.0                   backports_1.1.4            assertive.code_0.0-3       pillar_1.4.2              
[17] assertive.strings_0.0-3    rlang_0.4.0                rstudioapi_0.10.0-9000     data.table_1.12.2         
[21] callr_3.3.0                assertive_0.3-5            assertive.data_0.0-3       desc_1.2.0                
[25] devtools_2.1.0             readr_1.3.1                stringr_1.4.0              compiler_3.5.3            
[29] xfun_0.8                   pkgconfig_2.0.2            pkgbuild_1.0.3             tidyselect_0.2.5          
[33] tibble_2.1.3               roxygen2_6.1.1             assertive.sets_0.0-3       codetools_0.2-16          
[37] crayon_1.3.4               dplyr_0.8.3                withr_2.1.2                commonmark_1.7            
[41] assertive.base_0.0-7       magrittr_1.5               assertive.models_0.0-2     cli_1.1.0                 
[45] stringi_1.4.3              fs_1.3.1                   assertive.matrices_0.0-2   remotes_2.1.0             
[49] doParallel_1.0.14          xml2_1.2.0                 assertive.reflection_0.0-4 assertive.datetimes_0.0-2 
[53] vctrs_0.2.0                iterators_1.0.10           RODBC_1.3-15               tools_3.5.3               
[57] glue_1.3.1                 purrr_0.3.2                assertive.numbers_0.0-2    hms_0.5.0                 
[61] processx_3.4.0             pkgload_1.0.2              parallel_3.5.3             assertive.files_0.0-2     
[65] assertive.data.uk_0.0-2    sessioninfo_1.1.1          memoise_1.1.0              knitr_1.23                
[69] usethis_1.5.1

标签: rcran

解决方案


更新:编辑了我原来的帖子。

TLDR:确保您的库中没有空的包目录。

我花了一些时间深入研究这个问题,这就是正在发生的事情。

作为 R Rd 交叉引用检查的一部分,将执行以下代码语句(使用工具包中的一些函数):

base <- unlist(tools:::.get_standard_package_names()[c("base", "recommended")], 
    use.names = FALSE)
  base <- base[dir.exists(file.path(.Library, base))]
  aliases <- lapply(base, tools:::Rd_aliases, lib.loc = NULL)

base变量包含来自 CRAN 发行版的基本包和推荐包的列表。您可以在此处了解这些内容(转到 5.1):

https://cran.r-project.org/doc/FAQ/R-FAQ.html#R-Add_002dOn-Packages

tools:::.get_standard_package_names()实际上返回基本和推荐包的硬编码列表。然后,将消除默认系统库位置中不存在的包。之后,tools:::Rd_aliases应用于此列表。cluster就我而言,在位置输出中调用了一个文件夹.Library。与此同时,包裹本身也不见了。这就是我收到错误的原因。


推荐阅读