rstudio / packrat

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

Unreferenced packages marked as referenced #456

Open aschmu opened 6 years ago

aschmu commented 6 years ago

Hi, I'm having trouble wrapping my head around how packrat identifies packages that are supposedly referenced in my code. Here's the beginning of the output of packrat::status().

The following packages are referenced in your code, but are not present
in your library nor in packrat:

    slam
    tm

You will need to install these packages manually, then use
packrat::snapshot() to record these packages in packrat.

I'm pretty sure I don't import any of these packages and according to their CRAN pages they don't appear in any of my other used packages reverse dependencies. Even if I grep them in all of my source code, I can't find anything outside of the hidden .git repo of my project. Is it possible packrat looks for dependencies even in the git repo after the library is no longer used or mentioned (for example i referenced the package slam in a random script and then i realized i didn't need it but that reference still exists in an old commit and packrat thinks I still need it). Note that there's no mention of either packages in packrat.lock.

What's even stranger is that I don't have this issue on another machine with the same project setup, this only occured after I cloned the project on a separate server and bootstrapped packrat.

aschmu commented 6 years ago

In the mean time, I've put them in the ignored.packages.

kevinushey commented 6 years ago

What is the output of packrat:::appDependencies('.') in your project? My best guess is that a particular version of a package installed on your machine does depend on these packages. We shouldn't be crawling the .git folder for dependencies -- packrat effectively looks for all .R and .Rmd files in your project, and attempts to parse those for R package dependencies (which should ignore the .git folder).

aschmu commented 6 years ago

Here's the output :

  [1] "BH"             "DBI"            "DT"             "NLP"            "NMF"            "R.methodsS3"    "R.oo"           "R.utils"        "R6"            
 [10] "RColorBrewer"   "RCurl"          "RODBC"          "Rcpp"           "RcppParallel"   "Runuran"        "TTR"            "V8"             "XML"           
 [19] "assertthat"     "backports"      "base64enc"      "bindr"          "bindrcpp"       "bit"            "bit64"          "bitops"         "blob"          
 [28] "broom"          "colorspace"     "curl"           "data.table"     "dichromat"      "digest"         "doParallel"     "dplyr"          "dygraphs"      
 [37] "ensurer"        "evaluate"       "foreach"        "formattable"    "futile.logger"  "futile.options" "future"         "getopt"         "ggplot2"       
 [46] "globals"        "glue"           "gridBase"       "gtable"         "h2o"            "h2okit"         "highcharter"    "highr"          "hms"           
 [55] "htmltools"      "htmlwidgets"    "httpuv"         "httr"           "igraph"         "infuser"        "irlba"          "iterators"      "jsonlite"      
 [64] "juicer"         "kernlab"        "kimisc"         "knitr"          "labeling"       "lambda.r"       "lazyeval"       "listenv"        "loggr"         
 [73] "lubridate"      "magrittr"       "mailR"          "markdown"       "mime"           "mlapi"          "mnormt"         "munsell"        "nlme"          
 [82] "odbc"           "openssl"        "optparse"       "packrat"        "pkgconfig"      "pkgmaker"       "plogr"          "plyr"           "pryr"          
 [91] "psych"          "purrr"          "quantmod"       "rJava"          "readr"          "registry"       "reshape2"       "rlang"          "rlist"         
[100] "rmarkdown"      "rngtools"       "rprojroot"      "scales"         "shiny"          "shinydashboard" "slam"           "sourcetools"    "sparsepp"      
[109] "sqltools"       "stringi"        "stringr"        "text2vec"       "tibble"         "tidyr"          "tint"           "tm"             "wranglr"       
[118] "xgboost"        "xlsx"           "xlsxjars"       "xml2"           "xtable"         "xts"            "yaml"           "zoo"  

So apparently my projet does need slam and tm but I can't find any other packages that need those :

> .libPaths()
[1] "/xxx/proj/packrat/lib/x86_64-redhat-linux-gnu/3.3.2"    
[2] "/xxx/proj/packrat/lib-ext/x86_64-redhat-linux-gnu/3.3.2"
[3] "/xxx/proj/packrat/lib-R/x86_64-redhat-linux-gnu/3.3.2" 
> tools::dependsOnPkgs("slam")
character(0)
> tools::dependsOnPkgs("tm")
character(0)

But If I check for reverse dependencies of either package on my local user lib (ie not the packrat project lib), I can find RTextTools, maxent and tm.

kevinushey commented 6 years ago

For what it's worth, I see on my system (although not using packrat):

> tools::dependsOnPkgs("slam")
[1] "textshape"    "tm"           "topicmodels"  "wordcloud"    "quanteda"
[6] "syuzhet"      "clustRcompaR"
aschmu commented 6 years ago

Here's the output :

  [1] "BH"             "DBI"            "DT"             "NLP"            "NMF"            "R.methodsS3"    "R.oo"           "R.utils"        "R6"            
 [10] "RColorBrewer"   "RCurl"          "RODBC"          "Rcpp"           "RcppParallel"   "Runuran"        "TTR"            "V8"             "XML"           
 [19] "assertthat"     "backports"      "base64enc"      "bindr"          "bindrcpp"       "bit"            "bit64"          "bitops"         "blob"          
 [28] "broom"          "colorspace"     "curl"           "data.table"     "dichromat"      "digest"         "doParallel"     "dplyr"          "dygraphs"      
 [37] "ensurer"        "evaluate"       "foreach"        "formattable"    "futile.logger"  "futile.options" "future"         "getopt"         "ggplot2"       
 [46] "globals"        "glue"           "gridBase"       "gtable"         "h2o"            "h2okit"         "highcharter"    "highr"          "hms"           
 [55] "htmltools"      "htmlwidgets"    "httpuv"         "httr"           "igraph"         "infuser"        "irlba"          "iterators"      "jsonlite"      
 [64] "juicer"         "kernlab"        "kimisc"         "knitr"          "labeling"       "lambda.r"       "lazyeval"       "listenv"        "loggr"         
 [73] "lubridate"      "magrittr"       "mailR"          "markdown"       "mime"           "mlapi"          "mnormt"         "munsell"        "nlme"          
 [82] "odbc"           "openssl"        "optparse"       "packrat"        "pkgconfig"      "pkgmaker"       "plogr"          "plyr"           "pryr"          
 [91] "psych"          "purrr"          "quantmod"       "rJava"          "readr"          "registry"       "reshape2"       "rlang"          "rlist"         
[100] "rmarkdown"      "rngtools"       "rprojroot"      "scales"         "shiny"          "shinydashboard" "slam"           "sourcetools"    "sparsepp"      
[109] "sqltools"       "stringi"        "stringr"        "text2vec"       "tibble"         "tidyr"          "tint"           "tm"             "wranglr"       
[118] "xgboost"        "xlsx"           "xlsxjars"       "xml2"           "xtable"         "xts"            "yaml"           "zoo"  

So apparently my projet does need slam and tm but I can't find any other packages that need those :

> .libPaths()
[1] "/xxx/proj/packrat/lib/x86_64-redhat-linux-gnu/3.3.2"    
[2] "/xxx/proj/packrat/lib-ext/x86_64-redhat-linux-gnu/3.3.2"
[3] "/xxx/proj/packrat/lib-R/x86_64-redhat-linux-gnu/3.3.2" 
> tools::dependsOnPkgs("slam")
character(0)
> tools::dependsOnPkgs("tm")
character(0)

But If I check for reverse dependencies of either package on my local user lib (ie not the packrat project lib), I can find RTextTools, maxent and tm.

gsmafra commented 6 years ago

I was having the same problem until I activated my RStudio project. I had included nlme before but removed it from the source code afterwards but packrat::status continued to list it. Somehow packrat thought nlme was a dependency for lme4 in tools::dependsOnPkgs.