PredictiveEcology / Require

Simple R package to install and load packages conducive to a reproducible workflow
https://require.predictiveecology.org/
21 stars 6 forks source link

changing the default package cache dir using env var? #91

Open achubaty opened 1 year ago

achubaty commented 1 year ago

Setting env var R_REQUIRE_PKG_CACHE=/mnt/shared_cache/Require/packages does not properly create the directory structure of the default package cache directory. Specifically, I would expect that the R version (4.3 here) would be automatically appended to the path, rather than relying on the user to actively maintain and update their ~/.Renviron file to manually specify the R version (which also prevents multiple versions of R being used on the same machine).

d> getOption("Require.RPackageCache")
[1] "default"
d> RequirePkgCacheDir(FALSE)
  /home/achubaty/.cache/R/Require/packages/4.3 
"/home/achubaty/.cache/R/Require/packages/4.3" 
d> Require::getOptionRPackageCache()
[1] "/mnt/shared_cache/Require/packages"
eliotmcintire commented 3 months ago

This works now, as expected (with updated function names that start with cache...

> getOption("Require.RPackageCache")
NULL
> cachePkgDir(FALSE)
  /home/emcintir/.cache/R/Require/packages/4.3 
"/home/emcintir/.cache/R/Require/packages/4.3" 
> cacheGetOptionCachePkgDir()
  /home/emcintir/.cache/R/Require/packages/4.3 
"/home/emcintir/.cache/R/Require/packages/4.3" 
achubaty commented 2 months ago

Not working with Require 1.0.1

# ~/.Renviron
R_REQUIRE_PKG_CACHE=/mnt/shared_cache/Require/packages
> Require::cacheGetOptionCachePkgDir()
[1] "/mnt/shared_cache/Require/packages"