Friday, April 15, 2016

Loading dependencies from package-internal packrat library

Leave a Comment

I am building an R package with packrat. The package is fully tested and installation from the locally saved source file by

install.packages("myPackage.tar.gz", repos = NULL, type = "source") 

works if all dependencies (specified in the Imports: field) are installed on the local machine. However, I would like to install that package on another server where dependencies are not installed. When I try to do this, I get the error

"ERROR: dependencies ‘survey’, ‘dplyr’ are not available for package 'myPackage'" 

I also tried to install the packrat bundle which I created by calling

packrat::bundle(project = 'pathtomypackageproject', file = 'myPackage.tar.gz',                 include.lib = TRUE) 

but I get the same error.

I think the problem is that, upon installing 'myPackage', R searches the first element of .libPaths(), doesn't find anything and since "repos = NULL" is specified, has nowhere to install the packages from so the error is thrown.

A solution I'm still trying to avoid is to transfer a repository containing all dependencies to the server and pointing to the repository when installing the package. Ideally, I only have to transfer myPackage.tar.gz.

My question is if there is some way to point to the internal packrat library, where all dependencies can be found, and import the namespaces from there.

1 Answers

Answers 1

If you have included the list of packages to be imported in DESCRIPTION File, then you just need to do this while installation of your package:

  install.packages("myPackage",dependencies=TRUE) 
If You Enjoyed This, Take 5 Seconds To Share It

0 comments:

Post a Comment