Closed aronatkins closed 4 years ago
It looks like this issue manifests specifically because the Packrat src directory is set to the R temporary directory:
Sys.setenv(R_PACKRAT_SRC_DIR = tempdir())
The problem with doing this is that, when Packrat installs a package, it first decompresses the package sources into the temporary directory, and then builds and installs from those unpacked sources. I believe this is mostly legacy behavior done to protect against invalid archives that needed to be "fixed up" in various ways; e.g. correcting permissions on a package configure
script.
The simplest workaround, I think, would be to use a sub-directory of the R temporary directory as the Packrat source directory. A similar fix could be applied to decompressImpl()
here:
https://github.com/rstudio/packrat/blob/90520e2247f65b2b9fb21bfa804444bd5ab2b78c/R/install.R#L252
That is, instead of decompressing into tempdir()
we could use tempfile("packrat-decompress-")
or something.
tl;dr: ultimately this is a bug in Packrat; it can be fixed here but I think it could be easily worked around as well.
Modifying the original script to perform the following avoids .tar.gz
in the cache:
srcDir <- file.path(tempdir(), "packrat-src")
Sys.setenv(R_PACKRAT_SRC_DIR = srcDir)
I can confirm that #599 avoids .tar.gz
in the cache by replacing the install.packages
with:
install.packages("remotes", repos=c(CRAN="https://cran.rstudio.com/"))
remotes::install_github("rstudio/packrat", ref = "bugfix/packrat-decompress-path")
Given a
packrat/packrat.lock
:Restoring this environment retains the downloaded
.tar.gz
file within the package directory.R script to reproduce this issue; set
use_cache <- TRUE
to see the same problem when using a package cache.Run with Docker (so we can use the Linux binaries from RSPM):