Skip to contents

Checks that packages exist in the webR package repository and in the collection's extra repositories (packages.repos), the same ones bind() downloads from. Known limitations of some packages are added as notes, but they never change whether a package is available.

Usage

check_inventory(packages = NULL, path = ".")

Arguments

packages

Character vector of package names. If NULL, uses packages from the project configuration.

path

Project path. Used to read config if packages is NULL, and for the collection's extra repositories.

Value

A data frame with columns:

  • package: Package name

  • available: TRUE or FALSE, or NA when the package was not found and a repository could not be reached

  • version: Package version if available, NA otherwise

  • note: Known limitations, if any

  • repository: The repository that has the package, NA otherwise

  • cran_version: The version on CRAN, NA when CRAN lacks it or cannot be reached (the webrarian.cran_repo option names another repository, or FALSE to skip the comparison)

  • local_version: The version installed in this R session, NA if none

  • drift: "behind", "current" or "ahead", comparing the WebAssembly version with CRAN's

Examples

# \donttest{
# Queries the webR package repositories; without a network connection the
# availability is NA. The package index is cached under tempdir() here.
old <- Sys.getenv("R_USER_CACHE_DIR", unset = NA)
Sys.setenv(R_USER_CACHE_DIR = file.path(tempdir(), "webrarian-example-cache"))

check_inventory(c("dplyr", "ggplot2"))
#> ℹ Checking 2 packages against 1 repository...
#> ✔ 2 packages available
#>   package available version note              repository cran_version
#> 1   dplyr      TRUE   1.2.1 <NA> https://repo.r-wasm.org        1.2.1
#> 2 ggplot2      TRUE   4.0.3 <NA> https://repo.r-wasm.org        4.0.3
#>   local_version   drift
#> 1          <NA> current
#> 2          <NA> current

# Check every pre-built package a collection has configured
check_inventory(path = collection_example("data-analysis"))
#> ✔ Copied the "data-analysis" example to /tmp/RtmpQU25pJ/webrarian-data-analysis-206b3e85ce8
#> ℹ Checking 3 packages against 1 repository...
#> ✔ 3 packages available
#>   package available version note              repository cran_version
#> 1   dplyr      TRUE   1.2.1 <NA> https://repo.r-wasm.org        1.2.1
#> 2 ggplot2      TRUE   4.0.3 <NA> https://repo.r-wasm.org        4.0.3
#> 3  scales      TRUE   1.4.0 <NA> https://repo.r-wasm.org        1.4.0
#>   local_version   drift
#> 1          <NA> current
#> 2          <NA> current
#> 3          <NA> current

if (is.na(old)) Sys.unsetenv("R_USER_CACHE_DIR") else Sys.setenv(R_USER_CACHE_DIR = old)
# }