Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use R CMD Install without dependencies check?

Tags:

r

I'm running R CMD INSTALL --build package on a windows computer. 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.

Now sometimes I have the my package source code on a different windows computer. 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".

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?

After consulting --help, I tried the --no-test-load option but no luck.

like image 621
Wolfgang Wu Avatar asked Feb 19 '16 09:02

Wolfgang Wu


1 Answers

I reckon you want to build a .zip binary version of the package on a computer where not all dependencies are installed. 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.

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. 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. 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

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

like image 176
Joris Meys Avatar answered Sep 16 '22 16:09

Joris Meys