Search code examples
rpackrat

Packrat bootstrap doesn't find the packrat private library


I've built a Packrat project with several packages installed in the Packrat private library. I want to take the code and bring it, along with the Packrat library, to another system. The system I built the library in is Windows 7 running R 3.2.2 from Rstudio, and the system I'm moving it to is a Linux machine running R 3.1.2 from the command line. The version of packrat on the Windows machine is 0.4.6-1. Here is a rundown of the actions I took: on the Windows machine I ran

> packrat::bundle(include.lib=TRUE)

I took the resulting bundle and moved it over to the Linux system where I unzipped it using tar -zxvf packrat_bundle.tar.gz. I then entered the newly unzipped directory and started R. From there, packrat automatically bootstrapped (due to the line source("packrat/init.R") packrat placed in .Rprofile) and gave the following output

    Packrat is not installed in the local library -- attempting to bootstrap an installation...
> Installing packrat into project private library:
- '/home/code/packrat/lib/x86_64-unknown-linux-gnu/3.1.2'
* installing *source* package âpackratâ ...
** package âpackratâ successfully unpacked and MD5 sums checked
** R
** inst
** preparing package for lazy loading
** help
*** installing help indices
** building package indices
** testing if installed package can be loaded
* DONE (packrat)
> Attaching packrat
> Restoring library
Already up to date.
> Packrat bootstrap successfully completed. Entering packrat mode...
Updating system packages ('3.2.2' -> '3.1.2')
Packrat mode on. Using library in directory:
- "/home/code/packrat/lib"
Warning message:
In restore(restart = FALSE) :
  The most recent snapshot was generated using R version 3.2.2

After this, the output from .libPaths() is

> .libPaths()
[1] "/home/code/packrat/lib/x86_64-unknown-linux-gnu/3.1.2"
[2] "/home/code/packrat/lib-ext"
[3] "/home/code/packrat/lib-R"

The issue is that the library that I created on the Windows machine is contained in the directory /home/code/packrat/lib/x86_64-w64-mingw32/3.2.2. As such, I have to add that to .libPaths to get the packrat library to work correctly. I don't mind having to change .libPaths by hand, but I feel strongly like I might be doing something incorrectly that is causing the problem.

Thanks for any help!


Solution

  • It turns out that the issue I was having was that I hadn't snapshotted packrat before attempting to move it to the other system. I solved the problem by first running packrat::snapshot() and then proceeding mostly as before.

    I was under the mistaken assumption that by using packrat::bundle(include.lib=TRUE) that I could transfer my library that way. That's not the case, especially when the library needs to be moved to another system and rebuilt from source. Snapshotting first took care of the source rebuild, and packrat correctly bootstrapped.