High-level conan interface. This function creates a standalone script that can provision a library at any location. The script has no dependencies and can be copied to another system and create a library given an empty R installation.

conan(
  filename,
  packages,
  repos = NULL,
  policy = "upgrade",
  cran = NULL,
  dryrun = FALSE
)

Arguments

filename

Path to write the install script to. Any directory components will be created as needed.

packages

A character vector of packages to install. These can be names of CRAN packages or GitHub references etc; see pkgdepends::new_pkg_installation_proposal() for more details

repos

A character vector of repositories to use when installing. A suitable CRAN repo will be added if not detected (using the cran argument if provided)

policy

Should be either "lazy" or "upgrade", with a default of "upgrade"

cran

Fallback CRAN repo to use. If not given we will use https://cloud.r-project.org

dryrun

Logical, indicating if we should try a dryrun with conan_dryrun(); if this passes your requested packages seem satisfiable.

Value

Invisibly, the path to the created script. This can be run via Rscript to create a standalone library. The script will require exactly one argument: the path to the library to create. It will respond to the environment variables CONAN_PATH_BOOTSTRAP and CONAN_PATH_CACHE.

Examples

path <- conan::conan(tempfile(), "cpp11")
writeLines(tail(readLines(path)))
#> .dat <- parse_main_conan(name = "file183a6bbbbb20")
#> .packages <- "cpp11"
#> .repos <- c(CRAN = "https://cloud.r-project.org")
#> .policy <- "upgrade"
#> .lib <- .dat$lib
#> conan_install(.lib, .packages, policy = .policy, repos = .repos)