Check inventory (package availability in webR repositories)
Source:R/diagnostics.R
check_inventory.RdChecks 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.
Value
A data frame with columns:
package: Package nameavailable:TRUEorFALSE, orNAwhen the package was not found and a repository could not be reachedversion: Package version if available,NAotherwisenote: Known limitations, if anyrepository: The repository that has the package,NAotherwisecran_version: The version on CRAN,NAwhen CRAN lacks it or cannot be reached (thewebrarian.cran_repooption names another repository, orFALSEto skip the comparison)local_version: The version installed in this R session,NAif nonedrift:"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)
# }