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")

If you need the development version, you can install it from GitHub with:

pak::pak("r-lib/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: 44,780 x 32
#>    package     version depends suggests license imports linkingto archs enhances
#>    <chr>       <chr>   <chr>   <chr>    <chr>   <chr>   <chr>     <chr> <chr>   
#>  1 A3          1.0.0   R (>= ~ randomF~ GPL (>~ <NA>    <NA>      <NA>  <NA>    
#>  2 AATtools    0.0.2   R (>= ~ <NA>     GPL-3   magrit~ <NA>      <NA>  <NA>    
#>  3 ABACUS      1.0.0   R (>= ~ rmarkdo~ GPL-3   ggplot~ <NA>      <NA>  <NA>    
#>  4 ABC.RAP     0.9.0   R (>= ~ knitr, ~ GPL-3   graphi~ <NA>      <NA>  <NA>    
#>  5 ABCanalysis 1.2.1   R (>= ~ <NA>     GPL-3   plotrix <NA>      <NA>  <NA>    
#>  6 ABCoptim    0.15.0  <NA>    testtha~ MIT + ~ Rcpp, ~ Rcpp      ABCo~ <NA>    
#>  7 ABCp2       1.2     MASS    <NA>     GPL-2   <NA>    <NA>      <NA>  <NA>    
#>  8 ABHgenotyp~ 1.0.1   <NA>    knitr, ~ GPL-3   ggplot~ <NA>      <NA>  <NA>    
#>  9 ABM         0.3     <NA>    <NA>     GPL (>~ R6, Rc~ Rcpp      ABM.~ <NA>    
#> 10 ABPS        0.3     <NA>    testthat GPL (>~ kernlab <NA>      <NA>  <NA>    
#> # i 44,770 more rows
#> # i 23 more variables: license_restricts_use <chr>, priority <chr>,
#> #   license_is_foss <chr>, os_type <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>

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] 176
#> 
#> $size
#> [1] 204562277
pkg_cache_list()
#> # A data frame: 176 x 11
#>    fullpath    path  package url   etag  sha256 version platform built vignettes
#>    <chr>       <chr> <chr>   <chr> <chr> <chr>  <chr>   <chr>    <int>     <int>
#>  1 /Users/gab~ bin/~ diffvi~ http~ "\"2~ e8869~ 0.1.1   aarch64~    NA        NA
#>  2 /Users/gab~ src/~ testth~ <NA>   <NA> <NA>   0.0.0.~ source       1         0
#>  3 /Users/gab~ src/~ testth~ <NA>   <NA> <NA>   0.0.0.~ aarch64~     1         0
#>  4 /Users/gab~ bin/~ DT      http~ "\"1~ 69c62~ 0.27    aarch64~    NA        NA
#>  5 /Users/gab~ bin/~ R6      http~ "\"1~ 00398~ 2.5.1   aarch64~    NA        NA
#>  6 /Users/gab~ src/~ cli     <NA>   <NA> c37f3~ 3.6.1.~ source       1         0
#>  7 /Users/gab~ src/~ cli     <NA>   <NA> c37f3~ 3.6.1.~ aarch64~     1         0
#>  8 /Users/gab~ bin/~ glue    http~ "\"2~ 25019~ 1.6.2   aarch64~    NA        NA
#>  9 /Users/gab~ src/~ cli     <NA>   <NA> f6794~ 3.1.0.~ source       1         0
#> 10 /Users/gab~ src/~ cli     <NA>   <NA> f6794~ 3.1.0.~ aarch64~     1         0
#> # i 166 more rows
#> # i 1 more variable: rversion <chr>
pkg_cache_find(package = "dplyr")
#> # A data frame: 1 x 11
#>   fullpath     path  package url   etag  sha256 version platform built vignettes
#>   <chr>        <chr> <chr>   <chr> <chr> <chr>  <chr>   <chr>    <int>     <int>
#> 1 /Users/gabo~ bin/~ dplyr   http~ "\"1~ cb4f7~ 1.1.2   aarch64~    NA        NA
#> # i 1 more variable: rversion <chr>

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.

Installed packages

pkgcache contains a very fast DCF parser to parse ⁠PACKAGES*⁠ files, or the DESCRIPTION files in installed packages. parse_packages() parses all fields from PACKAGES, PACKAGES.gz or PACKAGES.rds files. parse_installed() reads all metadata from packages installed into a library:

parse_installed()
#> # A data frame: 329 x 97
#>    Package     Type  Title Version Date  Author Maintainer Description Copyright
#>    <chr>       <chr> <chr> <chr>   <chr> <chr>  <chr>      <chr>       <chr>    
#>  1 AsioHeaders Pack~ "'As~ 1.22.1~ 2022~ "Dirk~ Dirk Edde~ "'Asio' is~ file ins~
#>  2 BiocGeneri~ <NA>  "S4 ~ 0.46.0  <NA>  "The ~ Hervé Pag~ "The packa~ <NA>     
#>  3 BiocManager <NA>  "Acc~ 1.30.20 <NA>  "Mart~ Marcel Ra~ "A conveni~ <NA>     
#>  4 Biostrings  <NA>  "Eff~ 2.67.2  <NA>  "Herv~ Hervé Pag~ "Memory ef~ <NA>     
#>  5 DBI         <NA>  "R D~ 1.1.3   2022~ "R Sp~ Kirill Mü~ "A databas~ <NA>     
#>  6 DBItest     <NA>  "Tes~ 1.7.3   2022~ "Kiri~ Kirill Mü~ "A helper ~ <NA>     
#>  7 DT          Pack~ "A W~ 0.27    <NA>  "Yihu~ Yihui Xie~ "Data obje~ <NA>     
#>  8 Distributi~ <NA>  "Dis~ 0.6-0   2018~ "Davi~ David Sco~ "Utilities~ <NA>     
#>  9 Formula     <NA>  "Ext~ 1.2-5   2023~ "Achi~ Achim Zei~ "Infrastru~ <NA>     
#> 10 GenomeInfo~ <NA>  "Uti~ 1.35.17 <NA>  "Sona~ Hervé Pag~ "Contains ~ <NA>     
#> # i 319 more rows
#> # i 88 more variables: License <chr>, URL <chr>, BugReports <chr>,
#> #   NeedsCompilation <chr>, Packaged <chr>, Repository <chr>,
#> #   `Date/Publication` <chr>, Built <chr>, biocViews <chr>, Encoding <chr>,
#> #   Depends <chr>, Imports <chr>, Suggests <chr>, Collate <chr>, git_url <chr>,
#> #   git_branch <chr>, git_last_commit <chr>, git_last_commit_date <chr>,
#> #   `Authors@R` <chr>, VignetteBuilder <chr>, RoxygenNote <chr>, ...

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

Package environment variables

Using pkgcache in CRAN packages

If you use pkgcache in your CRAN package, please make sure that

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:

See Also

Useful links:


[Package pkgcache version 2.2.2 Index]