Skip to content

pak behavior can be finetuned with environment variables and options (as in base::options()).

R options affecting pak's behavior

Ncpus

Set to the desired number of worker processes for package installation. If not set, then pak will use the number of logical processors in the machine.

repos

The CRAN-like repositories to use. See base::options() for details.

pak configuration

Configuration entries (unless noted otherwise on this manual page) have a corresponding environment variable, and a corresponding option.

The environment variable is always uppercase and uses underscores as the word separator. It always has the PKG_ prefix.

The option is typically lowercase, use it uses underscores as the word separator, but it always has the pkg. prefix (notice the dot!).

Some examples:

Config entry nameEnv var nameOption name
platformsPKG_PLATFORMSpkg.platforms
cran_mirrorPKG_CRAN_MIRRORpkg.cran_mirror

pak configuration entries

  • ‘cache_dir’: (Env var: PKG_CACHE_DIR, option: pkg.cache_dir.) Directory to download the packages to. Defaults to a temporary directory within the R session temporary directory, see base::tempdir().

  • ‘cran_mirror’: (Env var: PKG_CRAN_MIRROR, option: pkg.cran_mirror.) CRAN mirror to use. Defaults to the repos option (see base::options()), if that's not set then https://cran.rstudio.com. See also pak::repo_add() and pak::repo_get()

  • ‘library’: (Env var: PKG_LIBRARY, option: pkg.library.) Package library to install packages to. It is also used for already installed packages when considering dependencies.

  • ‘metadata_cache_dir’: (Env var: PKG_METADATA_CACHE_DIR, option: pkg.metadata_cache_dir.) Location of metadata replica of pkgcache::cranlike_metadata_cache. Defaults to a temporary directory within the R session temporary directory, see base::tempdir().

  • ‘metadata_update_after’: (Env var: PKG_METADATA_UPDATE_AFTER, option: pkg.metadata_update_after.) A time interval as a difftime object. pak will update the metadata cache if it is older than this. The default is one day. The PKG_METADATA_UPDATE_AFTER environment variable may be set in seconds (s suffix), minutes (m suffix), hours (h suffix), or days (d suffix). E.g: 1d means one day.

  • ‘package_cache_dir’: (Env var: PKG_PACKAGE_CACHE_DIR, option: pkg.package_cache_dir.) Location of the package cache on the disk. See pak::cache_summary(). Default is selected by pkgcache.

  • ‘platforms’: (Env var: PKG_PLATFORMS, option: pkg.platforms.) Character vector of platforms to download or install packages for. See pkgdepends::default_platforms() for possible platform names. Defaults to the platform of the current R session, plus "source".

  • ‘r_versions’: (Env var: PKG_R_VERSIONS, option: pkg.r_versions.) Character vector, R versions to download or install packages for. It defaults to the current R version.

  • ‘sysreqs’: (Env var: PKG_SYSREQS, option: pkg.sysreqs.) Whether to look up and install system requirements. By default this is TRUE if the CI environment variable is set and the operating system is a supported Linux distribution: CentOS, Debian, Fedora, openSUSE, RedHat Linux, Ubuntu Linux or SUSE Linux Enterprise. The default will change as new platforms gain system requirements support.

  • ‘sysreqs_dry_run’: (Env var: PKG_SYSREQS_DRY_RUN, option: pkg.sysreqs_dry_run.) If TRUE, then pak only prints the system commands to install system requirements, but does not execute them.

  • ‘sysreqs_rspm_repo_id’: (Env var: PKG_SYSREQS_RSPM_REPO_ID, option: pkg.sysreqs_rspm_repo_id.) Posit Package Manager (formerly RStudio Package Manager) repository id to use for CRAN system requirements lookup. Defaults to the RSPM_REPO_ID environment variable, if set. If not set, then it defaults to 1.

  • ‘sysreqs_rspm_url’: (Env var: PKG_SYSREQS_RSPM_URL, option: pkg.sysreqs_rspm_url.) Root URL of Posit Package Manager (formerly RStudio Package Manager) for system requirements lookup. By default the RSPM_ROOT environment variable is used, if set. If not set, it defaults to https://packagemanager.posit.co.

  • ‘sysreqs_sudo’: (Env var: PKG_SYSREQS_SUDO, option: pkg.sysreqs_sudo.) Whether to use sudo to install system requirements, on Unix. By default it is TRUE on Linux if the effective user id of the current process is not the root user.

  • ‘sysreqs_verbose’: (Env var: PKG_SYSREQS_VERBOSE, option: pkg.sysreqs_verbose.) Whether to echo the output of system requirements installation. Defaults to TRUE if the CI environment variable is set.

  • ‘use_bioconductor’: (Env var: PKG_USE_BIOCONDUCTOR, option: pkg.use_bioconductor.) Whether to automatically use the Bioconductor repositories. Defaults to TRUE.

  • ‘windows_archs’: (Env var: PKG_WINDOWS_ARCHS, option: pkg.windows_archs.) Character scalar specifying which architectures to download/install for on Windows. Its possible values are:

    • "prefer-x64": Generally prefer x64 binaries. If the current R session is x64, then we download/install x64 packages. (These packages might still be multi-architecture binaries!) If the current R session is i386, then we download/install packages for both architectures. This might mean compiling packages from source if the binary packages are for x64 only, like the CRAN Windows binaries for R 4.2.x currently. "prefer-x64" is the default for R 4.2.0 and later.

    • "both": Always download/install packages for both i386 and x64 architectures. This might need compilation from source if the available binaries are for x64 only, like the CRAN Windows binaries for R 4.2.x currently. "both" is the default for R 4.2.0 and earlier.

Notes

From version 0.4.0 pak copies the PKG_* environment variables and the pkg.* options to the pak subprocess, where they are actually used, so you don't need to restart R or reaload pak after a configuration change.