switchr
switchr copied to clipboard
add continue_on_error feature in `switchTo()`
TL;DR: when creating a library, switchTo()
will quit with an error if the manifest is not carefully checked (e.g., if asking for some weird version that does not exist). Any way to issue a message instead of throwing an error? Some sort of force
or continue_on_error
? It takes a while to download 100s of libraries only to have to start all over on error.
I'm trying to recreate an environment used on a Dev R server to train a model into a Prod server. I don't have root access to the latter's default repository and it's ruining my life. Hoping your package is the answer. Here's the code I run
library(switchr, lib.loc = lib_loc)
package_manifest_gh <- GithubManifest("hadley/secure",
"hadley/multidplyr",
"PhilippPro/vimp",
"gsk3/taRifx.geo")
#capture packages in current env (get about 410)
package_manifest <- libManifest(known_manifest = package_manifest_gh)
#clean up manifest df and versions
temp_df <- manifest_df(package_manifest)
manifest_df(package_manifest)<-temp_df[which(!is.na(temp_df$type)),]
temp_df <- versions_df(package_manifest)
versions_df(package_manifest)<-subset(temp_df, name %in% manifest_df(package_manifest)$name)
#create switch library
switchrBaseDir("/usr/share/R/library")
switchTo(paste0("NoShowPackage",format(Sys.Date(),"%m_%Y")),
seed = package_manifest)
and error I end up with. I just had to go in, manually edit the manifest for multidplyr
and start over. Perhaps there's a smarter way to avoid redownloading by using lazyRepo()
, but I couldn't find in documentation
downloaded 0 bytes
sh: svn: command not found
Error in innerFun(src, pkg, version = vers, dir = dir, param = param, :
Unable to locate the specified version of packagemultidplyr
Thanks for the report. I will respond in more detail later, but to get things moving, can you attach the manifest you get (or just the part with multidplyr and its dependencies) that breaks things?
Sure, thanks! I'd already removed multidplyr
since production code was not using it, but here's the version and package dfs for the PKI
package which also threw an error
> package_manifest <- libManifest(record_versions = TRUE)
> package_manifest@pkg_versions %>% filter(name =="PKI")
name version
1 PKI 0.1-5
> package_manifest@pkg_manifest@manifest %>% filter(name =="PKI")
name url type branch subdir extra
1 PKI https://cran.rstudio.com/src/contrib CRAN trunk . <NA>
>
The stable version in CRAN is 0.1-3. I think I had downloaded 0.1-5 from GitHub because it had a patch I needed. Did not remember that when I was creating the manifest. It would be convenient if whenever a version cannot be found by switchTo()
, it would just install any available version. So like having record_versions = FALSE
, but only for the problematic packages.
It would be convenient if whenever a version cannot be found by switchTo(), it would just install any available version. So like having record_versions = FALSE, but only for the problematic packages.
I'm hesitant to support this because this could easily give rise to a broken package library where, for example, a versioned dependency is not met. Even worse, the versioned dependency might not be explicitly declared by the package, and things might just be broken. I suppose I could just warn on that, although, alternatively you can
I will look into supporting this, perhaps only in cases where there are no reverse dependencies for the package.