简体   繁体   English

如何使用R CMD安装而不依赖检查?

[英]How to use R CMD Install without dependencies check?

I'm running R CMD INSTALL --build package on a windows computer. 我在Windows计算机上运行R CMD INSTALL --build package My package imports a couple of other packages which themselves depend on some more packages. 我的包导入了几个本身依赖于更多包的其他包。 I have all dependencies installed in the local r_libs folder and everything works. 我在本地r_libs文件夹中安装了所有依赖项,一切正常。

Now sometimes I have the my package source code on a different windows computer. 现在有时我在不同的Windows计算机上有我的包源代码。 On this computer I don't have all the dependency packages installed. 在这台计算机上,我没有安装所有的依赖包。

When I try to use R CMD INSTALL --build package , I get the obvious " ERROR: dependencies 'package a', 'package b', etc, are not available for package" . 当我尝试使用R CMD INSTALL --build package ,我得到明显的“ ERROR: dependencies 'package a', 'package b', etc, are not available for package"

My question is: Can I build the package using R CMD INSTALL --build without the dependency checks and without removing the Import and Depends entries in the DESCRIPTION file? 我的问题是:我可以使用R CMD INSTALL --build构建包 - 没有相关性检查并且不删除DESCRIPTION文件中的ImportDepends条目吗?

After consulting --help , I tried the --no-test-load option but no luck. 在咨询了--help ,我尝试了--no-test-load选项,但没有运气。

I reckon you want to build a .zip binary version of the package on a computer where not all dependencies are installed. 我想你想在没有安装所有依赖项的计算机上构建包的.zip二进制版本。 And I'm afraid I'll have to disappoint you, as this won't be possible. 而且我担心我不得不让你失望,因为这是不可能的。

Building a binary package is done in two steps: first the package is installed from source (that's why you have to use R CMD INSTALL and then the created binaries are zipped in a convenient format for installation on a windows machine. The dependencies are checked at time of installation from source, and any missing dependencies will throw the error you're facing. 构建二进制包分两步完成:首先从源安装包(这就是为什么你必须使用R CMD INSTALL然后创建的二进制文件以方便的格式压缩以便在Windows机器上安装。依赖性在从源代码安装的时间,以及任何缺少的依赖项将引发您所面临的错误。

As R needs information from the dependencies at time of installation from source, you can't get around installing them before building the whole thing. 由于R在从源代码安装时需要来自依赖项的信息,因此在构建整个项目之前无法绕过安装它们。 This also makes sense. 这也是有道理的。 An installed package in R contains a set of .rds files which contain package information in a more convenient format for R. In order to create that information for the NAMESPACE file, it needs to be able to access the packages from which functions are imported. R中安装的软件包包含一组.rds文件,其中包含更方便R格式的软件包信息。为了为NAMESPACE文件创建该信息,它需要能够访问从中导入函数的软件包。 If not, it can't construct the correct information about the namespace. 如果不是,则无法构造有关命名空间的正确信息。

So your only option is to install the dependencies on the computer you use to build. 因此,您唯一的选择是在用于构建的计算机上安装依赖项。 And if you actually want to use the package on that computer, you'll have to install those dependencies anyway. 如果您确实想在该计算机上使用该软件包,则无论如何都必须安装这些依赖项。

More information: R Internals : https://cran.r-project.org/doc/manuals/r-release/R-ints.html#Package-Structure 更多信息:R Internals: https//cran.r-project.org/doc/manuals/r-release/R-ints.html#Package-Structure

Writing R Extensions: https://cran.r-project.org/doc/manuals/r-release/R-exts.html#Package-namespaces 编写R扩展: https//cran.r-project.org/doc/manuals/r-release/R-exts.html#Package-namespaces

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM