rstudio / packrat

Packrat is a dependency management system for R
http://rstudio.github.io/packrat/
399 stars 89 forks source link

packrat::snapshot fails looking for packages that aren't installed. #597

Open rbpatt2019 opened 4 years ago

rbpatt2019 commented 4 years ago

After starting a new project (devtools::create()), I initialised packrat (packrat::init()), then installed two packages - dplyr and Seurat. Upon calling packrat::snapshot(), I receive the following error:

[ins] r$> packrat::snapshot()
Error: Unable to retrieve package records for the following packages:
- 'testthat' 

Which is particularly confusing because:

[ins] r$> list.files(.libPaths())
  [1] "ape"          "askpass"      "assertthat"   "base"         "base64enc"    "bibtex"       "bitops"       "boot"         "caTools"      "class"        "cli"          "cluster"      "codetools"    "colorspace"
 [15] "compiler"     "cowplot"      "crayon"       "crosstalk"    "curl"         "data.table"   "datasets"     "digest"       "dplyr"        "ellipsis"     "fansi"        "farver"       "fitdistrplus" "FNN"
 [29] "foreign"      "future"       "future.apply" "gbRd"         "gdata"        "ggplot2"      "ggrepel"      "ggridges"     "globals"      "glue"         "gplots"       "graphics"     "grDevices"    "grid"
 [43] "gridExtra"    "gtable"       "gtools"       "hexbin"       "htmltools"    "htmlwidgets"  "httr"         "ica"          "igraph"       "irlba"        "isoband"      "jsonlite"     "KernSmooth"   "labeling"
 [57] "later"        "lattice"      "lazyeval"     "leiden"       "lifecycle"    "listenv"      "lmtest"       "lsei"         "magrittr"     "MASS"         "Matrix"       "MatrixModels" "metap"        "methods"
 [71] "mgcv"         "mime"         "mnormt"       "multcomp"     "munsell"      "mutoss"       "mvtnorm"      "nlme"         "nnet"         "npsurv"       "numDeriv"     "openssl"      "packrat"      "parallel"
 [85] "patchwork"    "pbapply"      "pillar"       "pkgconfig"    "plotly"       "plotrix"      "plyr"         "png"          "promises"     "purrr"        "quantreg"     "R6"           "RANN"         "RColorBrewer"
 [99] "Rcpp"         "RcppAnnoy"    "Rdpack"       "reshape2"     "reticulate"   "rlang"        "ROCR"         "rpart"        "RSpectra"     "rsvd"         "Rtsne"        "sandwich"     "scales"       "sctransform"
[113] "Seurat"       "sn"           "SparseM"      "spatial"      "splines"      "stats"        "stats4"       "stringi"      "stringr"      "survival"     "sys"          "tcltk"        "TFisher"      "TH.data"
[127] "tibble"       "tidyr"        "tidyselect"   "tools"        "tsne"         "utf8"         "utils"        "uwot"         "vctrs"        "viridisLite"  "withr"        "yaml"         "zoo"

Definitely does not have testthat as an entry or package.

I've tried a number of things recommended in similar issues (#511, #541), like removing and re-installing, or passing snapshot.sources = FALSE, or passing infer.dependencies = FALSE, but all result in the original error.

Apologies if I'm missing something super-basic, this is my first adventure with packrat!

kevinushey commented 4 years ago

packrat::snapshot() uses the union of packages included in your project, as well as packages already installed in your library paths. This most likely implies that Packrat discovered you're using testthat somewhere in your project, and so wants to ensure that it is added to the lockfile.

FWIW, I would strongly encourage you to check out renv as an alternative to Packrat; the API is ultimately the same but should overall be faster, more robust, and report errors more clearly.

rbpatt2019 commented 4 years ago

@kevinushey Thanks for the advice. I'll check out renv, too. Feel free to consider this closed!

rbpatt2019 commented 4 years ago

@kevinushey Thanks for the advice. I'll check out renv, too. Feel free to consider this closed!