Closed toph-allen closed 2 years ago
Packrat
RemoteRef: toph-untar-handling
RemoteSha: 108183392a8d733ed6bf66da65afab5b6de1c11c
GithubRepo: packrat
GithubUsername: rstudio
GithubRef: toph-untar-handling
GithubSHA1: 108183392a8d733ed6bf66da65afab5b6de1c11c
NeedsCompilation: no
Packaged: 2022-08-09 18:31:24 UTC; chaitamacpro
Built: R 4.1.1; ; 2022-08-09 18:31:25 UTC; unix
verified on packrat branchtoph-untar-handling
This PR incorporates #678, but goes further, so will supersede that PR.
Fixes #648
Intent
Packrat has previously forced the use of R's internal tar implementation. This is buggy in a number of situations, including any repository with a slug > 16 characters.
Note: The code is ready for review, but QA notes are incomplete.
Approach
Influenced by the approach taken in
renv
, we now define a functiontar_binary()
to encapsulate slightly more complex logic:TAR
is set, respect that;tar
on thePATH
;tar
and use that if it exists (seerenv
implementation)"internal"
and maybe emit a warning about long filenames.I put the function in
env.R
, because it gathers information about the environment.There were a number of locations where
tar()
oruntar()
were called withinternal
, and this PR changes all of them.Automated Tests
This PR adds automated tests. Note that it adds a dependency on
mockery
for the tests; I'm not sure if we're ok with this.There are five test functions that test the logical flow of the function in the following cases:
TAR
variable is defined returns the contents of that variabletar
binary on thePATH
returns that binarytar
binary on thePATH
returns"internal"
tar
returns the systemtar
tar
returns"internal"
QA Notes
You can validate that
packrat::restore()
still works by installing the the version of the package from this branch and runningpackrat::restore()
in an R session in the top level directory extracted from this .zip file: simple-rmd.zipThis will perform a Packrat restore. I'm not sure if there's a way to validate that the download path has been exercised from
restore()
though.You can also run
packrat:::tar_binary()
and see that it prints the expected path for your environment. For me, this looks like: