This function resolves the path to a package directory or tarball, handling both installed packages and source packages from CRAN.
resolve_pkg_path(
pkg,
cache_path = NULL,
force_fetch = FALSE,
repos = getOption("rdocdump.repos", getOption("repos"))
)A list containing:
pkg_path: Path to the package directory or tarball.
extracted_path: Path to the extracted package directory (if applicable).
tar_path: Path to the tarball if it was downloaded.
is_installed: Logical indicating if the package is installed.
A character string specifying the package. This can be:
an installed package name,
a full path to a package source directory,
a full path to a package archive file (tar.gz), or
a package name not installed (which will then be downloaded from CRAN).
A character string specifying the directory where kept temporary files will be stored.
By default, it uses the value of getOption("rdocdump.cache_path") which sets the cache directory to the temporary directory of the current R session.
logical. If TRUE, the package source will be fetched from CRAN as a tar.gz archive even if the package is already installed locally. Default is FALSE.
A character vector of repository URLs. By default, it uses the value of getOption("rdocdump.repos") which sets the repository URLs to the default R repositories and is itself set to c("CRAN" = "https://cloud.r-project.org") on package load to prevent accidental downloads of pre-built packages from Posit Package Manager and R Universe.