4

I'm using packrat for my local R package. I'm trying to add MultinomialCI as a dependency, but I can't get it loaded into packrat. Particularly, I don't know how to manually snapshot.

Rstudio's package viewer looks similar to this:

| Name          | Description | Version | Packrat | Source    |  
|-------------------------------------------------------------|  
| MultinomialCI | blah blah   | 1.0     |         |           |
|-------------------------------------------------------------|  

I understand I want the Packrat field to be non-empty or matching 1.0 in the Version field. I'm unsure why Source is blank - perhaps that is part of the issue? I installed MultinomialCI from CRAN using install.packages.

I've attempted to run snapshot manually with packrat::snapshot too:

> packrat::snapshot()
Error in findLocalRepoForPkg(pkg, repos, fatal = fatal) : 
  No package 'file182c4636542b' found in local repositories specified

I'm vexed by the "No package 'file182c4636542b' ..." error. It should be looking for my package's name, correct?

I've tried calling packrat::snapshot('C:\\My\\Package\\Directory') to no avail. Same error. :/

Here's my session info as well,

> sessionInfo()
R version 3.3.0 (2016-05-03)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows >= 8 x64 (build 9200)

locale:
[1] LC_COLLATE=English_United States.1252  LC_CTYPE=English_United States.1252   
[3] LC_MONETARY=English_United States.1252 LC_NUMERIC=C                          
[5] LC_TIME=English_United States.1252    

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

loaded via a namespace (and not attached):
[1] tools_3.3.0     packrat_0.4.7-1

I appreciate any help in advance!


Update

I attempted to run packrat::restore, which then recognized my package's name with the same error:

> packrat::restore()
Error in findLocalRepoForPkg(pkg, repos, fatal = fatal) : 
  No package 'my_pkg' found in local repositories specified
lmo
  • 37,904
  • 9
  • 56
  • 69
nev
  • 297
  • 3
  • 13
  • I'm getting a similar issue. So far I've had some success with uninstalling `YYY`, where `YYY` depends on the package in the error message (`file182c4636542b` for you, `rstanarm` for me). I think it might also work to try installing `file182c4636542b`, but I am still testing that out because it takes me hours to run `snapshot`. – eric_kernfeld Mar 30 '20 at 15:04
  • OK, by "hours" I meant 20 minutes, and freshly installing the offending package seems to work. – eric_kernfeld Mar 30 '20 at 15:19

1 Answers1

0

I have been encountering this error over and over, so I wrote a little recursion to restart the process until it's done.

snapshot_install_recurse = function(){
  tryCatch( 
    packrat::snapshot(), 
    error = function(e) {
      pkg = 
        e$message %>%
        strsplit("'") %>%
        extract2(1) %>% 
        extract2(2) 
      cat("Installing", pkg, "and restarting")
      install.packages(pkg)
      snapshot_install_recurse()
    }
  )
}
snapshot_install_recurse()
eric_kernfeld
  • 495
  • 5
  • 17