R.cache (>= 0.6.0) does the following to acquire a persistent cache (root) folder. This behavior was introduced after getting prompted by CRAN not to write to disk by default (because they found "funny" folders on their check servers) and a following email conversation with CRAN (2011-12-29), and getting an "ok with me" from Uwe@CRAN:
1. When loaded (not only attached) it checks for the existence of a cache folder (defaults to ~/.Rcache unless neither an R option nor an env var is set). If it is exists, then we're good to go. 2. If the cache folder does not exist, and in a non-interactive session, then a temporary cache folder specific to that R session is used. 3. If the cache folder does not exist, and in an interactive session, then the user will be queried whether they'd like to create ~/.Rcache (the default choice) or whether they like to use a temporary folder (just as in the non-interactive case). If accepting ~/.Rcache, then that will be available across sessions (Step 1 above). The gist is: Make sure to get the user's approval before storing anything permanently and don't doing anything that surprises the user, risk overwriting their files, etc. Here is a real-world user example on a "fresh" user account: # Non-interactive sessions or user does not approve $ Rscript -e "R.cache::getCacheRootPath()" [1] "/tmp/RtmpzIZT4o/.Rcache" $ R --vanilla > dummy <- loadNamespace("R.cache") The R.cache package needs to create a directory that will hold cache files. It is convenient to use one in the user's home directory, because it remains also after restarting R. Do you wish to create the '~/.Rcache/' directory? If not, a temporary directory (/tmp/RtmpMA4LTF/.Rcache) that is specific to this R session will be used. [Y/n]: n > R.cache::getCacheRootPath() [1] "/tmp/Rtmp0Ic5zQ/.Rcache" > quit("no") $ R --vanilla > R.cache::getCacheRootPath() The R.cache package needs to create a directory that will hold cache files. It is convenient to use one in the user's home directory, because it remains also after restarting R. Do you wish to create the '~/.Rcache/' directory? If not, a temporary directory (/tmp/RtmpzSJd3d/.Rcache) that is specific to this R session will be used. [Y/n]: n [1] "/tmp/RtmpzSJd3d/.Rcache" > quit("no") $ Rscript -e "R.cache::getCacheRootPath()" [1] "/tmp/Rtmpq1nx0H/.Rcache" # User approves or already approved $ R --vanilla > dummy <- loadNamespace("R.cache") The R.cache package needs to create a directory that will hold cache files. It is convenient to use one in the user's home directory, because it remains also after restarting R. Do you wish to create the '~/.Rcache/' directory? If not, a temporary directory (/tmp/RtmpMA4LTF/.Rcache) that is specific to this R session will be used. [Y/n]: Y > R.cache::getCacheRootPath() [1] "~/.Rcache/" > quit("no") $ Rscript -e "R.cache::getCacheRootPath()" [1] "~/.Rcache/" $ R --vanilla > dummy <- loadNamespace("R.cache") > R.cache::getCacheRootPath() [1] "~/.Rcache/" The same applies when using library("R.cache") as well as when the R.cache namespace is imported by another package. This behavior also plays well with 'R CMD check' and 'R CMD check --as-cran' where the cache folder will default to a temporary folder. It will also prevent run-time errors since there will always be a cache folder available (although it'll only survive the current session). R.cache works the same on all OSes. To further lower the risk for "what is this ~/.Rcache folder doing here?", R.cache also adds a ~/.Rcache/README.txt file explaining what that folder is and what created it. About what the default location should be: On Fri, Dec 1, 2017 at 8:06 AM, Sean Davis <seand...@gmail.com> wrote: [...] > On some systems, the user home directory is not large (such as on HPC > systems) or has strong quotas. The default user_cache_dir may not be the > best choice there. I agree with this but it's hard to find a solid simple alternative to the user's home folder. However, and on my todo list to investigate, https://cran.r-project.org/package=rappdirs may provide a better approach because it follows OS-specific recommendations. Back to writing to user's home folder: in HPC environments with limited home quota, I simply do things like ln -s /scratch/$USER/.Rcache ~/.Rcache. /Henrik On Fri, Dec 1, 2017 at 8:32 AM, Michael Love <michaelisaiahl...@gmail.com> wrote: > One solution if a developer really wants to make sure the user knows > that the function will store a cache somewhere would be to leave the > BiocFileCache location argument without a default value. > > _______________________________________________ > Bioc-devel@r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/bioc-devel _______________________________________________ Bioc-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/bioc-devel