| pkgcache-package {pkgcache} | R Documentation |
Cache for package data and metadata
Description
Metadata and package cache for CRAN-like repositories. This is a utility package to be used by package management tools that want to take advantage of caching.
Details
Metadata and package cache for CRAN-like repositories. This is a utility package to be used by package management tools that want to take advantage of caching.
Installation
You can install the released version of pkgcache from CRAN with:
install.packages("pkgcache")
Metadata cache
meta_cache_list() lists all packages in the metadata cache. It
includes Bioconductor package, and all versions (i.e. both binary and
source) of the packages for the current platform and R version.
(We load the pillar package, because it makes the pkgcache data frames print nicer, similarly to tibbles.)
library(pkgcache) library(pillar) meta_cache_list() #> # A data frame: 45,961 x 32 #> package version depends sugge~1 license imports linki~2 archs enhan~3 licen~4 #> <chr> <chr> <chr> <chr> <chr> <chr> <chr> <chr> <chr> <chr> #> 1 A3 1.0.0 R (>= ~ random~ GPL (>~ <NA> <NA> <NA> <NA> <NA> #> 2 AATtoo~ 0.0.2 R (>= ~ <NA> GPL-3 magrit~ <NA> <NA> <NA> <NA> #> 3 ABACUS 1.0.0 R (>= ~ rmarkd~ GPL-3 ggplot~ <NA> <NA> <NA> <NA> #> 4 ABC.RAP 0.9.0 R (>= ~ knitr,~ GPL-3 graphi~ <NA> <NA> <NA> <NA> #> 5 ABCana~ 1.2.1 R (>= ~ <NA> GPL-3 plotrix <NA> <NA> <NA> <NA> #> 6 ABCopt~ 0.15.0 <NA> testth~ MIT + ~ Rcpp, ~ Rcpp ABCo~ <NA> <NA> #> 7 ABCp2 1.2 MASS <NA> GPL-2 <NA> <NA> <NA> <NA> <NA> #> 8 ABHgen~ 1.0.1 <NA> knitr,~ GPL-3 ggplot~ <NA> <NA> <NA> <NA> #> 9 ABPS 0.3 <NA> testth~ GPL (>~ kernlab <NA> <NA> <NA> <NA> #> 10 ABSurv~ 0.1.0 R (>= ~ <NA> GPL-3 stats,~ <NA> <NA> <NA> <NA> #> # ... with 45,951 more rows, 22 more variables: os_type <chr>, priority <chr>, #> # license_is_foss <chr>, repodir <chr>, rversion <chr>, platform <chr>, #> # needscompilation <chr>, ref <chr>, type <chr>, direct <lgl>, status <chr>, #> # target <chr>, mirror <chr>, sources <list>, filesize <int>, sha256 <chr>, #> # sysreqs <chr>, built <chr>, published <dttm>, deps <list>, md5sum <chr>, #> # path <chr>, and abbreviated variable names 1: suggests, 2: linkingto, #> # 3: enhances, 4: license_restricts_use
meta_cache_deps() and meta_cache_revdeps() can be used to look up
dependencies and reverse dependencies.
The metadata is updated automatically if it is older than seven days,
and it can also be updated manually with meta_cache_update().
See the cranlike_metadata_cache R6 class for a lower level API, and
more control.
Package cache
Package management tools may use the pkg_cache_* functions and in
particular the package_cache class, to make use of local caching of
package files.
The pkg_cache_* API is high level, and uses a user level cache:
pkg_cache_summary() #> $cachepath #> [1] "/Users/gaborcsardi/Library/Caches/org.R-project.R/R/pkgcache/pkg" #> #> $files #> [1] 321 #> #> $size #> [1] 420283448
pkg_cache_list() #> # A data frame: 321 x 11 #> fullpath path package url etag sha256 version platf~1 built vigne~2 #> <chr> <chr> <chr> <chr> <chr> <chr> <chr> <chr> <int> <int> #> 1 /Users/gaborc~ src/~ tibble http~ "\"a~ acf30~ 3.1.8 source NA NA #> 2 /Users/gaborc~ bin/~ rmsfact http~ "\"4~ 44c34~ 0.0.3 aarch6~ NA NA #> 3 /Users/gaborc~ bin/~ fortun~ http~ "\"3~ 943db~ 1.5-4 aarch6~ NA NA #> 4 /Users/gaborc~ bin/~ cowsay http~ "\"6~ 4d9c3~ 0.8.0 aarch6~ NA NA #> 5 /Users/gaborc~ bin/~ multic~ http~ "\"1~ 55859~ 0.1.5 aarch6~ NA NA #> 6 /Users/gaborc~ src/~ cli <NA> <NA> 8b0ce~ <NA> <NA> 0 NA #> 7 /Users/gaborc~ src/~ cli <NA> <NA> 8b0ce~ 3.5.0.~ source 1 0 #> 8 /Users/gaborc~ src/~ cli <NA> <NA> 8b0ce~ 3.5.0.~ aarch6~ 1 0 #> 9 /Users/gaborc~ src/~ cli <NA> <NA> bc503~ <NA> <NA> 0 NA #> 10 /Users/gaborc~ src/~ cli <NA> <NA> bc503~ 3.5.0.~ source 1 0 #> # ... with 311 more rows, 1 more variable: rversion <chr>, and abbreviated #> # variable names 1: platform, 2: vignettes
pkg_cache_find(package = "dplyr") #> # A data frame: 5 x 11 #> fullp~1 path package url etag sha256 version platf~2 built vigne~3 rvers~4 #> <chr> <chr> <chr> <chr> <chr> <chr> <chr> <chr> <int> <int> <chr> #> 1 /Users~ bin/~ dplyr http~ "\"6~ 162b5~ 1.0.10 aarch6~ NA NA <NA> #> 2 /Users~ bin/~ dplyr http~ "\"6~ 9014f~ 1.0.9 aarch6~ NA NA <NA> #> 3 /Users~ src/~ dplyr http~ "\"1~ 8cb05~ 1.1.0 source NA NA <NA> #> 4 /Users~ bin/~ dplyr http~ "\"6~ 54679~ 1.1.0 aarch6~ NA NA <NA> #> 5 /Users~ bin/~ dplyr http~ "\"1~ 6ebb2~ 1.1.0 aarch6~ NA NA <NA> #> # ... with abbreviated variable names 1: fullpath, 2: platform, 3: vignettes, #> # 4: rversion
pkg_cache_add_file() can be used to add a file,
pkg_cache_delete_files() to remove files, pkg_cache_get_files() to
copy files out of the cache.
The package_cache class provides a finer API.
Bioconductor support
Both the metadata cache and the package cache support Bioconductor by
default, automatically. See the BioC_mirror option and the
R_BIOC_MIRROR and R_BIOC_VERSION environment variables below to
configure Bioconductor support.
Package Options
The
BioC_mirroroption can be used to select a Bioconductor mirror. This takes priority over theR_BIOC_MIRRORenvironment variable.-
pkgcache_timeoutis the HTTP timeout for all downloads. It is in seconds, and the limit for downloading the whole file. Defaults to 3600, one hour. It corresponds to theTIMEOUTlibcurl option. -
pkgcache_connecttimeoutis the HTTP timeout for the connection phase. It is in seconds and defaults to 30 seconds. It corresponds to theCONNECTTIMEOUTlibcurl option. -
pkgcache_low_speed_limitandpkgcache_low_speed_timeare used for a more sensible HTTP timeout. If the download speed is less thanpkgcache_low_speed_limitbytes per second for at leastpkgcache_low_speed_timeseconds, the download errors. They correspond to theLOW_SPEED_LIMITandLOW_SPEED_TIMEcurl options.
Package environment variables
The
R_BIOC_VERSIONenvironment variable can be used to override the default Bioconductor version detection and force a given version. E.g. this can be used to force the development version of Bioconductor.The
R_BIOC_MIRRORenvironment variable can be used to select a Bioconductor mirror. TheBioC_mirroroption takes priority over this, if set.-
PKGCACHE_PPM_REPOis the name of the Posit Package Manager repository to use. Defaults to"cran". -
PKGCACHE_PPM_URLis the base URL of the Posit Package Manager instance to use. It defaults to the URL of the Posit Public Package Manager instance at https://packagemanager.posit.co/client/#/. -
PKGCACHE_TIMEOUTis the HTTP timeout for all downloads. It is in seconds, and the limit for downloading the whole file. Defaults to 3600, one hour. It corresponds to theTIMEOUTlibcurl option. Thepkgcache_timeoutoption has priority over this, if set. -
PKGCACHE_CONNECTTIMEOUTis the HTTP timeout for the connection phase. It is in seconds and defaults to 30 seconds. It corresponds to theCONNECTTIMEOUTlibcurl option. Thepkgcache_connecttimeoutoption takes precedence over this, if set. -
PKGCACHE_LOW_SPEED_LIMITandPKGCACHE_LOW_SPEED_TIMEare used for a more sensible HTTP timeout. If the download speed is less thanPKGCACHE_LOW_SPEED_LIMITbytes per second for at leastPKGCACHE_LOW_SPEED_TIMEseconds, the download errors. They correspond to theLOW_SPEED_LIMITandLOW_SPEED_TIMEcurl options. Thepkgcache_low_speed_timeandpkgcache_low_speed_limitoptions have priority over these environment variables, if they are set. -
R_PKG_CACHE_DIRis used for the cache directory, if set. (Otherwiserappdirs::user_cache_dir()is used, see alsometa_cache_summary()andpkg_cache_summary()).
Using pkgcache in CRAN packages
If you use pkgcache in your CRAN package, please make sure that
you don’t use pkgcache in your examples, and
you set the
R_USER_CACHE_DIRenvironment variable to a temporary directory (e.g. viatempfile()) during test cases. See thetests/testthat/setup.Rfile in pkgcache for an example.
This is to make sure that pkgcache does not modify the user’s files
while running R CMD check.
Code of Conduct
Please note that the pkgcache project is released with a Contributor Code of Conduct. By contributing to this project, you agree to abide by its terms.
License
MIT (c) Posit Software, PBC
Author(s)
Maintainer: Gábor Csárdi csardi.gabor@gmail.com
Other contributors:
RStudio [copyright holder, funder]
See Also
Useful links:
Report bugs at https://github.com/r-lib/pkgcache/issues