创建一个包含本地存储的依赖项的R包



我正在开发一个R包,该包使用本地存储的依赖项,但我不知道如何在DESCRIPTION文件中正确列出该包。我正在构建的包是PackageA,它依赖于PackageB。在我从一位同事那里共享了PackageB的zip文件夹后,它被本地存储在我的驱动器上。这两个软件包仅供内部使用,不会存储在任何存储库中。我发现以下页面显示了如何使用DESCRIPTION文件中的Remotes:标签来完成这项工作:

https://cran.r-project.org/web/packages/devtools/vignettes/dependencies.html

这可以用以下代码完成,但当我尝试时,我收到一个错误,如下所示:

#Example from linked vignette
# Local
Remotes: local::/pkgs/testthat
#Both of these attempts produce the same error
#1. Specify file path to the unpacked version of the package in my R library
Remotes: local::C:/Users/name/library/PackageB
#2. Specify file path to the original .zip version of the package
Remotes: local::C:/Users/name/library/PackageB.zip
#devtools::build() error
ERROR: package installation failed
Error in (function (command = NULL, args = character(), error_on_status = TRUE,  : 
System command 'Rcmd.exe' failed, exit status: 1, stdout + stderr:
E> * checking for file 'C:UsersnamePackageA/DESCRIPTION' ... OK
E> * preparing 'PackageA':
E> * checking DESCRIPTION meta-information ... OK
E> * installing the package to build vignettes
E>       -----------------------------------
E> ERROR: dependency 'PackageB' is not available for package 'PackageA'
E> * removing 'C:/Users/tmpfolder/PackageA'
E>       -----------------------------------
E> ERROR: package installation failed
#Rstudio Install and Restart error; I would build the source after this but it doesn't get that far
Error: Dependency package(s) 'PackageB' not available.
Backtrace:
x
1. +-base::suppressPackageStartupMessages(...)
2. | -base::withCallingHandlers(expr, packageStartupMessage = function(c) tryInvokeRestart("muffleMessage"))
3. -devtools::document(...)
4.   -roxygen2::roxygenise(pkg$path, roclets)
5.     -roxygen2:::load_code(base_path)
6.       -pkgload::load_all(path, helpers = FALSE, attach_testthat = FALSE)
7.         -pkgload:::load_imports(path)
8.           -pkgload:::abort_for_missing_packages(res, imports$package)
Warning message:
In (function (dep_name, dep_ver = "*")  :
Dependency package 'PackageB' not available.
Execution halted
Exited with status 1.

我想知道我是否错误地指定了文件路径,但可能更复杂。

"你不能"通过标准回购作为CCD_ 4等需要访问包。您可以做的是创建一个本地repo(例如,drat包使这变得很容易(,然后将该repo添加到测试框上的一组已知repo(添加到options(repos),或使用drat辅助函数(并进行测试。

或者,您可以使用Additional_repositories字段,但仅用于Suggests:,因此在第一个包中使用第二个包中的代码之前,您必须测试是否存在。

简而言之;只是安装了包装";对测试来说不够好。只是R对包裹的看法不同。

最新更新