### Example Output of sysreqs_platforms() Source: https://pak.r-lib.org/reference/sysreqs_platforms This example shows the typical output of `sysreqs_platforms()`, illustrating the columns and data format returned. It includes OS names, distributions, version information, and commands for updating package metadata and installing packages. ```r sysreqs_platforms() #> # A data frame: 19 × 9 #> name os id distribution version version_match update_command #> #> 1 Ubunt… linux ubun… ubuntu * NA apt-get -y up… #> 2 Debia… linux debi… debian * NA apt-get -y up… #> 3 CentO… linux cent… centos * major NA #> 4 Rocky… linux rocky rockylinux * major NA #> 5 Rocky… linux rock… rockylinux * major NA #> 6 AlmaL… linux alma… rockylinux * major NA #> 7 Red H… linux rhel redhat 6 major NA #> 8 Red H… linux rhel redhat 7 major NA #> 9 Red H… linux rhel redhat * major NA #> 10 Red H… linux redh… redhat 6 major NA #> 11 Red H… linux redh… redhat 7 major NA #> 12 Red H… linux redh… redhat * major NA #> 13 Fedor… linux fedo… fedora * NA NA #> 14 openS… linux open… opensuse * NA NA #> 15 openS… linux open… opensuse * NA NA #> 16 openS… linux open… opensuse * NA NA #> 17 SUSE … linux sles sle * NA NA #> 18 SUSE … linux sle sle * NA NA #> 19 Alpin… linux alpi… alpine * minor NA #> # ℹ 2 more variables: install_command , query_command ``` -------------------------------- ### Display First 10 Installed System Packages Source: https://pak.r-lib.org/reference/sysreqs_list_system_packages This example shows how to display the first 10 rows of the data frame returned by sysreqs_list_system_packages(). It illustrates the typical output format. ```r sysreqs_list_system_packages()[1:10,] ``` -------------------------------- ### Example: List PPM Platforms Source: https://pak.r-lib.org/reference/ppm_platforms An example demonstrating the usage of `ppm_platforms()` within an `if (FALSE)` block, typically used for examples that should not be run automatically. ```r if (FALSE) { ppm_platforms() } ``` -------------------------------- ### List all installed system packages and capabilities Source: https://pak.r-lib.org/reference/sysreqs Use `sysreqs_list_system_packages()` to get a cross-platform list of all installed system packages and their capabilities. The output is a data frame showing package status, name, version, and provided capabilities. ```R pak::sysreqs_list_system_packages() ``` -------------------------------- ### Example usage of ppm_has_binaries() Source: https://pak.r-lib.org/reference/ppm_has_binaries This example demonstrates how to use `ppm_has_binaries()` within a conditional block. It also shows `system_r_platform()` for context, though this specific example is designed not to run by default. ```r if (FALSE) { system_r_platform() ppm_has_binaries() } ``` -------------------------------- ### Install Development Version from GitHub Source: https://pak.r-lib.org/reference/pkg_install Installs the development version of a package directly from a GitHub repository. Shows the installation of multiple dependencies and packaging/building the development version. ```r pkg_install("tidyverse/dplyr") ``` -------------------------------- ### Reference Installed Package Source: https://pak.r-lib.org/reference/pak_package_sources Use 'installed::' to refer to a package already installed in a specific library path. ```r installed::~/R/3.6/crayon ``` -------------------------------- ### Install Source Package with Missing System Dependency Source: https://pak.r-lib.org/reference/sysreqs Demonstrates the output when attempting to install a source R package ('RPostgres') that requires a system library ('libpq-dev') which is not installed. The installation fails, and pak provides details on the missing dependency and how to install it. ```r pak::pkg_install("RPostgres?source") ## + plogr 0.2.0 ## x Missing 1 system package. You'll probably need to install it ## manually: ## + libpq-dev - RPostgres ## i No downloads are needed, 2 pkgs (1.47 MB) are cached ## v Installed plogr 0.2.0 (1.1s) ## i Building RPostgres 1.4.5 ## x Failed to build RPostgres 1.4.5 ## Registered S3 methods overwritten by 'callr': ## method from ## format.callr_status_error ## print.callr_status_error ## Error: ## ! error in pak subprocess ## Caused by error in `stop_task_build(state, worker)`: ## ! Failed to build source package 'RPostgres' ## Full installation output: ## * installing *source* package ‘RPostgres’ ... ## ** package ‘RPostgres’ successfully unpacked and MD5 sums checked ## staged installation is only possible with locking ## ** using non-staged installation ## Using PKG_CFLAGS= ## Using PKG_LIBS=-lpq ## Using PKG_PLOGR= ## ------------------------- ANTICONF ERROR --------------------------- ## Configuration failed because libpq was not found. Try installing: ## * deb: libpq-dev libssl-dev (Debian, Ubuntu, etc) ## * rpm: postgresql-devel (Fedora, EPEL) ## * rpm: postgreql8-devel, psstgresql92-devel, postgresql93-devel, or pos ## tgresql94-devel (Amazon Linux) ## * csw: postgresql_dev (Solaris) ## * brew: libpq (OSX) ## If libpq is already installed, check that either: ## (i) 'pkg-config' is in your PATH AND PKG_CONFIG_PATH contains ## a libpq.pc file; or ## (ii) 'pg_config' is in your PATH. ## If neither can detect , you can set INCLUDE_DIR ## and LIB_DIR manually via: ## R CMD INSTALL --configure-vars='INCLUDE_DIR=... LIB_DIR=' ## --------------------------[ ERROR MESSAGE ]---------------------------- ## :1:10: fatal error: libpq-fe.h: No such file or directory ## compilation terminated. ## ----------------------------------------------------------------------- ## ERROR: configuration failed for package ‘RPostgres’ ## * removing ‘/tmp/RtmpsOXbPZ/pkg-lib4a492949a49e/RPostgres’ ## --- ## Backtrace: ## 1. pak::pkg_install("RPostgres?source") ## 2. pak:::remote(function(...) get("pkg_install_do_plan", asNamespace("pa ## k"))… at package.R:84:3 ## 3. err$throw(res$error) at subprocess.R:115:5 ## --- ## Subprocess backtrace: ## 1. base::withCallingHandlers(cli_message = function(msg) { ## 2. get("pkg_install_do_plan", asNamespace("pak"))(...) ## 3. proposal$install() ## 4. pkgdepends::install_package_plan(plan, lib = private$library, num_wo ## rkers = nw… ## 5. base::withCallingHandlers({ … ## 6. pkgdepends:::handle_events(state, events) ## 7. pkgdepends:::handle_event(state, i) ## 8. pkgdepends:::stop_task(state, worker) ## 9. pkgdepends:::stop_task_build(state, worker) ## 10. base::throw(new_pkg_build_error("Failed to build source package {pkg ## }", … ## 11. | base::signalCondition(cond) ## 12. global (function (e) … ## Execution halted ``` -------------------------------- ### Query System Requirements for Multiple Packages Source: https://pak.r-lib.org/reference/sysreqs Use pkg_sysreqs() to find system dependencies for a list of R packages. This example shows the output for Ubuntu 22.04, including apt-get install commands and package-to-dependency mappings. ```R pak::pkg_sysreqs(c("curl", "xml2", "devtools", "CHRONOS")) ``` -------------------------------- ### R: Basic pkg_install Usage Source: https://pak.r-lib.org/reference/pkg_install Demonstrates the default usage of the pkg_install function to install a package. It installs the specified package and its required dependencies. ```r pkg_install( pkg, lib = .libPaths()[[1L]], upgrade = FALSE, ask = interactive(), dependencies = NA ) ``` -------------------------------- ### Install R Package with System Dependencies Source: https://pak.r-lib.org/reference/sysreqs Installs an R package, automatically identifying and installing any required system packages if pak is run with superuser privileges on a supported platform. This example shows installing the 'RPostgres' package. ```R pak::pkg_install("RPostgres") ``` -------------------------------- ### Install Latest Version of Dependency with pak Source: https://pak.r-lib.org/reference/faq.html To ensure a dependency is installed from source (e.g., to get the latest version), use the `=?source` syntax. ```R pak::pkg_install(c("tibble", "cli=?source")) ``` -------------------------------- ### Install Package from Source with pak Source: https://pak.r-lib.org/reference/faq.html To force the installation of a source package instead of a binary package, use the `?source` parameter with `pkg_install()`. ```R pak::pkg_install("tibble?source") ``` -------------------------------- ### Install a package from a URL Source: https://pak.r-lib.org/reference/get-started.html Installs a package from a direct URL. The URL can point to a built package file (e.g., .tar.gz, .zip) or a package source tree. ```r pak::pkg_install( "url::https://cran.r-project.org/src/contrib/Archive/tibble/tibble_3.1.7.tar.gz" ) ``` -------------------------------- ### Example: List Available PPM Snapshots (Conditional) Source: https://pak.r-lib.org/reference/ppm_snapshots This is a conditional example demonstrating the usage of `ppm_snapshots()`. The code is wrapped in `if (FALSE)` and will not execute by default. ```r if (FALSE) { ppm_snapshots() } ``` -------------------------------- ### List Installed System Packages Source: https://pak.r-lib.org/reference/sysreqs_list_system_packages Call this function to get a data frame of installed system packages. The output includes package status, name, version, and capabilities. ```r sysreqs_list_system_packages() ``` -------------------------------- ### local_install() Source: https://pak.r-lib.org/llms.txt Install a package tree. ```APIDOC ## local_install() ### Description Install a package tree. ### Method Not specified (likely an R function call) ### Endpoint Not applicable (R function) ### Parameters None specified in the source. ### Request Example ```R local_install("path/to/package/tree") ``` ### Response None specified in the source. ``` -------------------------------- ### Example Usage of R Platform Functions Source: https://pak.r-lib.org/reference/system_r_platform Demonstrates the typical usage of `system_r_platform()` and `system_r_platform_data()` within an R session. This example is typically run interactively. ```r if (FALSE) { system_r_platform() system_r_platform_data() } ``` -------------------------------- ### Install Local Package Tree Source: https://pak.r-lib.org/reference/local_install Installs a local package tree from the specified root directory. By default, it installs required dependencies and upgrades packages if necessary. Use this to install a project's local packages and their dependencies. ```r local_install( root = ".", lib = .libPaths()[1], upgrade = TRUE, ask = interactive(), dependencies = NA ) ``` -------------------------------- ### Get Configured Repositories Source: https://pak.r-lib.org/reference/repo_get Retrieves the data frame of currently configured repositories. This is useful for inspecting the repository setup. ```r repo_get() ``` -------------------------------- ### Install Development Dependencies Source: https://pak.r-lib.org/reference/local_install_dev_deps Installs all dependencies, including development dependencies, for a package tree. Defaults to the current directory and the first library path. Can be configured to upgrade packages and control which dependency types are installed. ```r local_install_dev_deps( root = ".", lib = .libPaths()[1], upgrade = TRUE, ask = interactive(), dependencies = TRUE ) ``` -------------------------------- ### Install Pre-built Binary of pak Source: https://pak.r-lib.org/reference/install Installs a self-contained, dependency-free pre-built binary of pak from GitHub. This method is supported on various Linux, macOS, and Windows systems. ```R install.packages("pak", repos = sprintf( "https://r-lib.github.io/p/pak/stable/%s/%s/%s", .Platform$pkgType, R.Version()$os, R.Version()$arch )) ``` -------------------------------- ### pkg_install Source: https://pak.r-lib.org/reference/pkg_install Installs specified packages and their dependencies into a designated library path. It supports installing from CRAN, GitHub, URLs, and local directories, with options to control dependency installation and package upgrades. ```APIDOC ## pkg_install ### Description Installs one or more packages and their dependencies into a single package library. ### Arguments - **pkg**: Package names or package references. Can be from CRAN, Bioconductor, GitHub (with optional tag/branch), URL, or the current working directory. - **lib**: Character vector of library paths. The first path is the target installation directory. Additional paths are used by the solver to find existing dependencies. - **upgrade**: If `FALSE` (default), installs the minimum required versions. If `TRUE`, ensures the latest versions of the package and all dependencies are installed. - **ask**: Logical, whether to ask for confirmation when installing a different version of an already installed package. Defaults to `interactive()`. - **dependencies**: Specifies which types of dependencies to install. `NA` for required dependencies only, `TRUE` for required, optional, and development dependencies, `FALSE` to not install any dependencies. ### Value Invisibly returns a data frame with information about the installed package(s). ``` -------------------------------- ### Install All Dependencies of a Local Package Source: https://pak.r-lib.org/reference/get-started.html Use this function to install all development dependencies for a local R package. It will list the packages to be installed, updated, and cached. ```r pak::local_install_dev_deps() ``` -------------------------------- ### Install a Local Package and Dependencies with pak Source: https://pak.r-lib.org/llms.txt Use this snippet to install a local R package and ensure all its dependencies are also installed. This is useful for development or when working with packages not yet published to a repository. ```r pak::local_install("cli") ``` -------------------------------- ### Install specified packages with pak() Source: https://pak.r-lib.org/reference/pak Use pak() to install specific packages by name or remote specification. Extra arguments are passed to pkg_install(). ```r pak(pkg = NULL, ...) ``` -------------------------------- ### Check System Requirements for All Installed Packages Source: https://pak.r-lib.org/reference/sysreqs_check_installed This snippet demonstrates how to use `sysreqs_check_installed()` without arguments to check system requirements for all packages installed in the default library path. This function is useful for auditing dependencies on a system. The output shows which system packages are required and whether they are installed. ```r sysreqs_check_installed() #> system package installed required by #> -------------- -- ----------- #> cmake ✔ fs, nanonext #> git ✔ credentials, gitcreds #> gsfonts ✔ magick #> libcurl4-openssl-dev ✔ curl #> libfontconfig1-dev ✔ systemfonts #> libfreetype6-dev ✔ ragg, systemfonts, textshaping #> libfribidi-dev ✔ textshaping #> libgit2-dev ✔ gert #> libharfbuzz-dev ✔ textshaping #> libicu-dev ✔ stringi #> libjpeg-dev ✔ ragg #> libmagick++-dev ✔ magick #> libnode-dev ✔ V8 #> libpng-dev ✔ ragg #> libsecret-1-dev ✔ keyring #> libssl-dev ✔ curl, openssl, PKI #> libtiff-dev ✔ ragg #> libuv1-dev ✔ fs #> libwebp-dev ✔ ragg #> libx11-dev ✔ clipr #> libxml2-dev ✔ xml2 #> make ✔ fs, httpuv, rticles, sass #> pandoc ✔ knitr, pkgdown, rmarkdown #> zlib1g-dev ✔ httpuv ``` -------------------------------- ### Install a CRAN Package Source: https://pak.r-lib.org/reference/pkg_install Installs a specified package from CRAN. Shows the process of checking for dependencies and caching packages. ```r pkg_install("dplyr") ``` -------------------------------- ### local_install_dev_deps Source: https://pak.r-lib.org/reference/local_install_dev_deps Installs all dependencies of a package tree (or source package file), without installing the package tree itself. It installs the development dependencies as well, specified in the `Suggests` field of `DESCRIPTION`. ```APIDOC ## local_install_dev_deps ### Description Installs all dependencies of a package tree (or source package file), without installing the package tree itself. It installs the development dependencies as well, specified in the `Suggests` field of `DESCRIPTION`. ### Arguments - **root** (character) - Path to the package tree. - **lib** (character vector) - Character vector of library paths to consider when creating the installation plan. The first library path is the target where packages will be installed. Additional library paths, if provided, are visible to the solver as candidates for satisfying dependency requirements. If a needed package is found here at an acceptable version, it won't be re-installed in `lib[1]`. Base and recommended packages in `.Library` are always considered, i.e. a recommended package is only duplicated in `lib[1]` if a newer version is required. - **upgrade** (logical) - When `FALSE`, the default, pak does the minimum amount of work to give you the latest version(s) of `pkg`. It will only upgrade dependent packages if `pkg`, or one of their dependencies explicitly require a higher version than what you currently have. It will also prefer a binary package over to source package, even if the binary package is older. When `upgrade = TRUE`, pak will ensure that you have the latest version(s) of `pkg` and all their dependencies. - **ask** (logical) - Whether to ask for confirmation when installing a different version of a package that is already installed. Installations that only add new packages never require confirmation. - **dependencies** (logical or NA) - What kinds of dependencies to install. Most commonly one of the following values: `NA`: only required (hard) dependencies, `TRUE`: required dependencies plus optional and development dependencies, `FALSE`: do not install any dependencies. (You might end up with a non-working package, and/or the installation might fail.) See [Package dependency types](https://pak.r-lib.org/reference/package-dependency-types.md) for other possible values and more information about package dependencies. ``` -------------------------------- ### Install Optional Dependencies Source: https://pak.r-lib.org/reference/pak_install_extra Installs optional packages for pak, such as 'pillar', which improves data frame printing. Set 'upgrade = TRUE' to install or upgrade to the latest versions. ```r pak_install_extra(upgrade = FALSE) ``` -------------------------------- ### Install Binary Package with Missing System Dependency Source: https://pak.r-lib.org/reference/sysreqs Illustrates the scenario where installing a binary R package ('RPostgres') succeeds even with a missing system dependency ('libpq-dev'). However, loading the package will fail until the dependency is met. ```r pak::pkg_install("RPostgres") library(RPostgres) ## → Will install 17 packages. ## → All 17 packages (0 B) are cached. ## + DBI 1.1.3 ## + RPostgres 1.4.5 + x libpq-dev ## + Rcpp 1.0.10 ## + bit 4.0.5 ## + bit64 4.0.5 ## + blob 1.2.4 ## + cli 3.6.1 ## + generics 0.1.3 ## + glue 1.6.2 ## + hms 1.1.3 ## + lifecycle 1.0.3 ``` -------------------------------- ### Install and display local package dependency tree Source: https://pak.r-lib.org/reference/local_deps Use `local_deps_tree` to install required dependencies and print the dependency tree. Set `upgrade = TRUE` for the latest package versions. `dependencies = NA` installs only hard dependencies. ```r local_deps_tree(root = ".", upgrade = TRUE, dependencies = NA) ``` -------------------------------- ### Example of ppm_r_versions() usage Source: https://pak.r-lib.org/reference/ppm_r_versions This is a commented-out example demonstrating the usage of ppm_r_versions(). It is typically used within an if (FALSE) block to prevent execution during standard package checks. ```r if (FALSE) { ppm_r_versions() } ``` -------------------------------- ### Install Nightly Build of pak Source: https://pak.r-lib.org/reference/install Installs a nightly binary build of pak from the development tree. This is available for the same systems as the stable pre-built binaries. ```R install.packages("pak", repos = sprintf( "https://r-lib.github.io/p/pak/devel/%s/%s/%s", .Platform$pkgType, R.Version()$os, R.Version()$arch )) ``` -------------------------------- ### Install Packages from Lockfile Source: https://pak.r-lib.org/reference/lockfile_install Installs packages listed in a lock file. Use this to recreate a specific package environment. The 'update' argument controls whether to install only missing or outdated packages. ```r lockfile_install(lockfile = "pkg.lock", lib = .libPaths()[1], update = TRUE) ``` -------------------------------- ### lockfile_install() Source: https://pak.r-lib.org/llms.txt Install packages based on a lock file. ```APIDOC ## lockfile_install() ### Description Install packages based on a lock file. ### Method Not specified (likely an R function call) ### Endpoint Not applicable (R function) ### Parameters None specified in the source. ### Request Example ```R lockfile_install("path/to/lockfile") ``` ### Response None specified in the source. ``` -------------------------------- ### handle_package_not_found() Source: https://pak.r-lib.org/llms.txt Install missing packages on the fly. ```APIDOC ## handle_package_not_found() ### Description Install missing packages on the fly when a package is not found. ### Method Not specified (likely an R function call) ### Endpoint Not applicable (R function) ### Parameters None specified in the source. ### Request Example ```R handle_package_not_found("package_name") ``` ### Response None specified in the source. ``` -------------------------------- ### local_install_dev_deps() Source: https://pak.r-lib.org/llms.txt Install all (development) dependencies of a package tree. ```APIDOC ## local_install_dev_deps() ### Description Install all (development) dependencies of a package tree. ### Method Not specified (likely an R function call) ### Endpoint Not applicable (R function) ### Parameters None specified in the source. ### Request Example ```R local_install_dev_deps("path/to/package/tree") ``` ### Response None specified in the source. ``` -------------------------------- ### Install and display local development dependency tree Source: https://pak.r-lib.org/reference/local_deps Use `local_dev_deps_tree` to install required and development dependencies and print the dependency tree. Set `upgrade = TRUE` for the latest package versions. `dependencies = TRUE` includes optional and development dependencies. ```r local_dev_deps_tree(root = ".", upgrade = TRUE, dependencies = TRUE) ``` -------------------------------- ### Install pak from Stable or Devel Stream Source: https://pak.r-lib.org/reference/install Installs pak from either the 'stable' (latest CRAN release) or 'devel' (development tree) stream by specifying the stream in the repository URL. ```R stream <- "stable" install.packages("pak", repos = sprintf( "https://r-lib.github.io/p/pak/%s/%s/%s/%s", stream, .Platform$pkgType, R.Version()$os, R.Version()$arch )) ``` -------------------------------- ### local_install_deps() Source: https://pak.r-lib.org/llms.txt Install the dependencies of a package tree. ```APIDOC ## local_install_deps() ### Description Install the dependencies of a package tree. ### Method Not specified (likely an R function call) ### Endpoint Not applicable (R function) ### Parameters None specified in the source. ### Request Example ```R local_install_deps("path/to/package/tree") ``` ### Response None specified in the source. ``` -------------------------------- ### Install Local R Package Source: https://pak.r-lib.org/reference/get-started.html Use pak::local_install() to install packages from the local R library. This function checks for updates and caches packages if available. ```r pak::local_install() ``` -------------------------------- ### Install Package from GitHub with Any Version of Another Dependency Source: https://pak.r-lib.org/reference/pak_package_sources Use 'any::' for dependencies where any compatible version is acceptable. This prevents conflicts when installing packages from non-CRAN sources like GitHub. ```r pak::pkg_install(c("any::glue", "r-lib/cli")) ``` -------------------------------- ### sysreqs_list_system_packages() Source: https://pak.r-lib.org/llms.txt List installed system packages. ```APIDOC ## sysreqs_list_system_packages() ### Description List installed system packages. ### Method Not specified (likely an R function call) ### Endpoint Not applicable (R function) ### Parameters None specified in the source. ### Request Example ```R sysreqs_list_system_packages() ``` ### Response None specified in the source. ``` -------------------------------- ### Install from URL (zip) Source: https://pak.r-lib.org/reference/pak_package_sources Use 'url::' to specify a direct URL to a compressed directory of package trees (.zip). pak will attempt to build it. ```r url::https://github.com/tidyverse/stringr/archive/HEAD.zip ``` -------------------------------- ### Install from URL (tar.gz) Source: https://pak.r-lib.org/reference/pak_package_sources Use 'url::' to specify a direct URL to an R package archive (.tar.gz). pak will download and build if necessary. ```r url::https://cloud.r-project.org/src/contrib/Archive/cli/cli_1.0.0.tar.gz ``` -------------------------------- ### Install Packages with Conflicting Dependencies Source: https://pak.r-lib.org/reference/pak_solver Demonstrates how pak detects and reports conflicts when installing packages with incompatible dependency versions or sources. This example shows a conflict between 'r-lib/pkgcache@conflict' and 'r-lib/cli@message'. ```r pak::pkg_install(c("r-lib/pkgcache@conflict", "r-lib/cli@message")) ``` -------------------------------- ### Remotes Field Example Source: https://pak.r-lib.org/reference/pak_package_sources Specify custom package sources in the Remotes field of a DESCRIPTION file. This allows dependencies to be installed from locations other than CRAN. ```r Imports: glue Remotes: r-lib/glue, r-lib/httr@v0.4, klutometis/roxygen#142, r-lib/testthat@c67018fa4970 ``` -------------------------------- ### List Packages in an R Library Source: https://pak.r-lib.org/reference/get-started.html Use pak::lib_status() to get a data frame of all installed packages in a specified library path. This is useful for auditing or understanding the library's contents. ```r pak::lib_status(Sys.getenv("R_LIBS_USER")) ``` -------------------------------- ### Download a GitHub package Source: https://pak.r-lib.org/reference/pkg_download Demonstrates downloading a package directly from a GitHub repository. This example specifies that only the source package should be downloaded. ```r pkg_download("r-lib/pak", platforms = "source") #> i No downloads are needed, 1 pkg is cached ``` -------------------------------- ### Install Hard Dependencies of a Package Tree Source: https://pak.r-lib.org/reference/local_install_deps Use `local_install_deps()` to install only the required dependencies for a package tree. This function installs necessary packages without installing the package tree itself. ```r local_install_deps( root = ".", lib = .libPaths()[1], upgrade = TRUE, ask = interactive(), dependencies = NA ) ``` -------------------------------- ### Equivalent Package References with Parameters Source: https://pak.r-lib.org/reference/pak_package_sources Demonstrates two equivalent ways to reference a package with source and nocache parameters. The first uses flags, and the second explicitly sets boolean values to true. ```R cran::testthat?source&nocache cran::testthat?source=true&nocache=true ``` -------------------------------- ### List system requirements for a specific platform Source: https://pak.r-lib.org/reference/sysreqs_db_list Use this snippet to list the system requirements for a given platform, such as 'ubuntu-22.04'. The output is a data frame detailing dependency names, patterns, packages, and installation commands. ```r sysreqs_db_list(sysreqs_platform = "ubuntu-22.04") #> # A data frame: 131 × 5 #> name patterns packages pre_install post_install #> #> 1 Abseil #> 2 apparmor #> 3 atk #> 4 automake #> 5 berkeleydb #> 6 blender #> 7 blosc #> 8 boost #> 9 bowtie2 #> 10 bwidget #> # ℹ 121 more rows ``` -------------------------------- ### Run Authenticated Proxy Source: https://pak.r-lib.org/reference/repo-auth Starts a web proxy for testing authenticated repositories. Requires webfakes and callr packages. ```R repo <- webfakes::new_app_process(pak:::auth_proxy_app()) repo$url() #> [1] "http://127.0.0.1:59571/" ``` -------------------------------- ### Install Packages from GitHub Source: https://pak.r-lib.org/llms.txt Install a package directly from a GitHub repository by specifying the repository owner and name. This is useful for installing development versions or packages not yet on CRAN. ```r pak::pkg_install("tidyverse/tibble") ``` -------------------------------- ### Example .netrc file format Source: https://pak.r-lib.org/reference/repo_auth A .netrc file stores credentials for multiple hosts. Ensure it is only readable by you. ```text machine myhost.mydomain.com login myuser password secret machine myhost2.mydomain.com login myuser password secret login anotheruser password stillsecret ``` -------------------------------- ### local_install Source: https://pak.r-lib.org/reference/local_install Installs a package tree (or source package file), together with its dependencies. This function is equivalent to pkg_install("local::."). ```APIDOC ## local_install ### Description Installs a package tree (or source package file), together with its dependencies. ### Usage ```r local_install( root = ".", lib = .libPaths()[1], upgrade = TRUE, ask = interactive(), dependencies = NA ) ``` ### Arguments * `root` (character) - Path to the package tree. * `lib` (character vector) - Character vector of library paths to consider when creating the installation plan. The first library path is the target where packages will be installed. Additional library paths, if provided, are visible to the solver as candidates for satisfying dependency requirements. If a needed package is found here at an acceptable version, it won't be re-installed in `lib[1]`. Base and recommended packages in `.Library` are always considered, i.e. a recommended package is only duplicated in `lib[1]` if a newer version is required. * `upgrade` (logical) - When `FALSE`, the default, pak does the minimum amount of work to give you the latest version(s) of `pkg`. It will only upgrade dependent packages if `pkg`, or one of their dependencies explicitly require a higher version than what you currently have. It will also prefer a binary package over to source package, even if the binary package is older. When `upgrade = TRUE`, pak will ensure that you have the latest version(s) of `pkg` and all their dependencies. * `ask` (logical) - Whether to ask for confirmation when installing a different version of a package that is already installed. Installations that only add new packages never require confirmation. * `dependencies` (logical or NA) - What kinds of dependencies to install. Most commonly one of the following values: `NA`: only required (hard) dependencies, `TRUE`: required dependencies plus optional and development dependencies, `FALSE`: do not install any dependencies. (You might end up with a non-working package, and/or the installation might fail.) See [Package dependency types](https://pak.r-lib.org/reference/package-dependency-types.md) for other possible values and more information about package dependencies. ### Value Data frame, with information about the installed package(s). ### Details `local_install()` is equivalent to `pkg_install("local::.")`. ### See also Other local package trees: [`local_deps()`](https://pak.r-lib.org/reference/local_deps.md), [`local_deps_explain()`](https://pak.r-lib.org/reference/local_deps_explain.md), [`local_install_deps()`](https://pak.r-lib.org/reference/local_install_deps.md), [`local_install_dev_deps()`](https://pak.r-lib.org/reference/local_install_dev_deps.md), [`local_package_trees`](https://pak.r-lib.org/reference/local_package_trees.md), [`pak()`](https://pak.r-lib.org/reference/pak.md) ``` -------------------------------- ### Install local package dependencies Source: https://pak.r-lib.org/reference/local_deps Use `local_deps` to install required dependencies for a package tree. Set `upgrade = TRUE` to use the most recent package versions. `dependencies = NA` installs only hard dependencies. ```r local_deps(root = ".", upgrade = TRUE, dependencies = NA) ``` -------------------------------- ### Install Local Package Dependencies Source: https://pak.r-lib.org/reference/get-started.html Installs all dependencies required for a package located in the current directory. This function is part of package development workflows. ```r pak::local_install_deps() ``` -------------------------------- ### Explain GitHub usethis dependency on cli and ps Source: https://pak.r-lib.org/reference/pkg_deps_explain Illustrates how to use pkg_deps_explain with a GitHub-sourced package ('r-lib/usethis') and multiple target dependencies ('cli', 'ps'). It shows dependencies on 'cli' and indicates that 'ps' is not a direct dependency in this context. ```r pkg_deps_explain("r-lib/usethis", c("cli", "ps")) ``` -------------------------------- ### Install or Update Packages from CRAN/Bioconductor Source: https://pak.r-lib.org/llms.txt Use this function to install a specified package and its dependencies from CRAN or Bioconductor. It handles the download and build process. ```r pak::pkg_install("tibble") ``` -------------------------------- ### Download a CRAN package Source: https://pak.r-lib.org/reference/pkg_download Demonstrates downloading the 'forcats' package from CRAN. Shows how to check if downloads are needed and inspect the download details. ```r dl <- pkg_download("forcats") #> i No downloads are needed, 2 pkgs (641.53 kB) are cached dl #> # A data frame: 2 × 35 #> ref type direct direc…¹ status package version license needs…² #> #> 1 forcats standard TRUE TRUE OK forcats 0.5.2 MIT + … FALSE #> 2 forcats standard TRUE TRUE OK forcats 0.5.2 MIT + … FALSE #> # … with 26 more variables: priority , md5sum , sha256 , #> # filesize , built , platform , rversion , #> # repotype , repodir , target , deps , #> # mirror , sources , remote , error , #> # metadata , extra , dep_types , params , #> # sysreqs , cache_status , fulltarget , #> # fulltarget_tree , download_status , … dl$fulltarget #> [1] "./bin/macosx/big-sur-arm64/contrib/4.2/forcats_0.5.2.tgz" #> [2] "./src/contrib/forcats_0.5.2.tar.gz" ``` -------------------------------- ### pkg_status Source: https://pak.r-lib.org/reference/pkg_status Displays the installation status and locations of specified R packages. This function is useful for inspecting where packages are installed and retrieving detailed metadata about them. ```APIDOC ## pkg_status ### Description Displays installed locations of a package. ### Usage ```r pkg_status(pkg, lib = .libPaths()) ``` ### Arguments * **pkg** (character or character vector) - Name of one or more installed packages to display status for. * **lib** (character vector) - One or more library paths to lookup packages status in. By default all libraries are used. ### Value Data frame with data about installations of `pkg`. It has always has columns: * `biocviews`: the corresponding field from `DESCRIPTION`, it must be present for all Bioconductor packages, other packages typically don't have it. * `built`: the `Built` field from `DESCRIPTION`. * `depends`, `suggests`, `Imports`, `linkingto`, `enhances`: the corresponding fields from the `DESCRIPTION` files. * `deps`: A list or data frames, the dependencies of the package. It has columns: `ref`, `type` (dependency type in lowercase), `package` (dependent package, or `R`), `op` and `version`, for last two are for version requirement. `op` can be `>=`, `>`, `==` or `<=`, although the only the first one is common in practice. * `library`: path to the package library containing the package. * `license`: from `DESCRIPTION`. * `md5sum`: from `DESCTIPTION`, typically `NA`, except on Windows. * `needscompilation`: from `DESCRIPTION`, this column is logical. * `package`: package name. * `platform`: from the `Built` field in `DESCRIPTION`, the current platform if missing from `DESCRIPTION`. * `priority`: from `DESCRIPTION`, usually `base`, `recommended`, or missing. * `ref`: the corresponding `installed::*` package reference. * `repository`: from `DESCRIPTION`. For packages from a CRAN repository this is `CRAN`, some other repositories, e.g. R-universe adds the repository URL here. * `repotype`: `cran`, `bioc` or missing. * `rversion`: from the `Built` field. If no such field, then the current R version. * `sysreqs`: the `SystemRequirements` field from `DESCRIPTION`. * `title`: package title. * `type`: always `installed`. * `version`: package version (as string). Most of these columns are unchanged from `DESCRIPTION`, but pak also adds a couple. ### Notes: * In addition, it also has all `remote*` and `config/needs/*` entries from the `DESCRIPTION` files. (Case insensitive.) * All columns are of type `character`, except for `needscompilation`, which is logical and `deps`, which is a list columns. * If an entry is missing for a package, it is set to `NA`. * Note that column names are lowercase, even if the corresponding entries are not in `DESCRIPTION`. * The order of the columns is not deterministic, so don't assume any order. * Additional columns might be present, these are internal for pak and should not be used in user code. ### Examples ```r pkg_status("MASS") ``` ``` -------------------------------- ### List packages in the default library Source: https://pak.r-lib.org/reference/lib_status Call `pkg_list()` with the path to the first library in `.libPaths()` to list installed packages. ```r pkg_list(lib = .libPaths()[1]) ``` -------------------------------- ### Get package status in the default library Source: https://pak.r-lib.org/reference/lib_status Call `lib_status()` with the path to the first library in `.libPaths()` to get a data frame of package statuses. ```r lib_status(lib = .libPaths()[1]) ``` -------------------------------- ### ppm_platforms() Source: https://pak.r-lib.org/llms.txt List all platforms supported by Posit Package Manager (PPM). ```APIDOC ## ppm_platforms() ### Description List all platforms supported by Posit Package Manager (PPM). ### Method Not specified (likely an R function call) ### Endpoint Not applicable (R function) ### Parameters None specified in the source. ### Request Example ```R ppm_platforms() ``` ### Response None specified in the source. ``` -------------------------------- ### ppm_snapshots() Source: https://pak.r-lib.org/llms.txt List all available Posit Package Manager (PPM) snapshots. ```APIDOC ## ppm_snapshots() ### Description List all available Posit Package Manager (PPM) snapshots. ### Method Not specified (likely an R function call) ### Endpoint Not applicable (R function) ### Parameters None specified in the source. ### Request Example ```R ppm_snapshots() ``` ### Response None specified in the source. ``` -------------------------------- ### sysreqs_list_system_packages Source: https://pak.r-lib.org/reference/sysreqs_list_system_packages Lists installed system packages on the current platform. It returns a data frame containing the status, package name, installed version, and capabilities of each package. ```APIDOC ## sysreqs_list_system_packages ### Description Lists installed system packages on the current platform. It returns a data frame containing the status, package name, installed version, and capabilities of each package. ### Method ```r sysreqs_list_system_packages() ``` ### Parameters This function does not take any parameters. ### Value Returns a data frame with the following columns: - `status` (character): Two or three characters, the notation of `dpkg` on Debian-based systems. "ii" means the package is correctly installed. On `RPM` based systems it is always "ii" currently. - `package` (character): Name of the system package. - `version` (character): Installed version of the system package. - `capabilities` (list of character vectors): The capabilities provided by the package. ### Examples ```r sysreqs_list_system_packages()[1:10,] ``` ``` -------------------------------- ### lib_status Source: https://pak.r-lib.org/reference/lib_status Retrieves a data frame containing status information for all packages installed in a given library path. This function is useful for inspecting the state of your package installations. ```APIDOC ## lib_status ### Description Retrieves a data frame containing status information for all packages installed in a given library path. This function is useful for inspecting the state of your package installations. ### Function Signature lib_status(lib = .libPaths()[1]) ### Parameters #### Arguments - **lib** (string) - Path to the library directory. Defaults to the first path in `.libPaths()`. ### Value A data frame with detailed information about each installed package. Columns include: - `biocviews`: Bioconductor views field. - `built`: The `Built` field from `DESCRIPTION`. - `depends`, `suggests`, `Imports`, `linkingto`, `enhances`: Dependency fields from `DESCRIPTION`. - `deps`: A list or data frame of package dependencies, including package name, version requirements, and type. - `library`: The path to the package library. - `license`: Package license from `DESCRIPTION`. - `md5sum`: MD5 checksum from `DESCRIPTION`. - `needscompilation`: Logical, indicates if the package requires compilation. - `package`: Package name. - `platform`: The platform the package was built for. - `priority`: Package priority (e.g., `base`, `recommended`). - `ref`: The installed package reference. - `repository`: The repository from which the package was installed. - `repotype`: Type of repository (`cran`, `bioc`, or missing). - `rversion`: The R version the package was built for. - `sysreqs`: System requirements from `DESCRIPTION`. - `title`: Package title. - `type`: Always `installed` for this function. - `version`: Package version string. ### Notes - Additional columns like `remote*` and `config/needs/*` may be present. - `needscompilation` is logical; `deps` is a list column. - Missing entries are set to `NA`. - Column names are lowercase. - The order of columns is not guaranteed. - Internal `pak` columns may be present but should not be used by users. ``` -------------------------------- ### Configure Proxy as Main CRAN Repository Source: https://pak.r-lib.org/reference/repo-auth Adds a configured proxy as the main CRAN repository using repo_add(). The default username is 'username' and password is 'token'. ```R repo_add(CRAN = repo$url(), username = "username") repo_get() #> x Did not find credentials for repo , keyring #> lookup failed (macos backend). #> # A data frame: 6 x 7 #> name url type r_version bioc_version username has_password #> * #> 1 CRAN http://usern~ cran * username FALSE #> 2 BioCsoft https://bioc~ bioc 4.4.2 3.20 NA #> 3 BioCann https://bioc~ bioc 4.4.2 3.20 NA #> 4 BioCexp https://bioc~ bioc 4.4.2 3.20 NA #> 5 BioCworkflows https://bioc~ bioc 4.4.2 3.20 NA #> 6 BioCbooks https://bioc~ bioc 4.4.2 3.20 NA ``` -------------------------------- ### Explain Local Dependencies Source: https://pak.r-lib.org/reference/local_deps_explain Use `local_deps_explain()` to understand the required dependencies of packages in a local tree. Set `upgrade = TRUE` to consider the latest available versions. ```r local_deps_explain(deps, root = ".", upgrade = TRUE, dependencies = NA) ``` -------------------------------- ### Display installed locations of a package Source: https://pak.r-lib.org/reference/pkg_status Use pkg_status to check the installation details of a specific package. This function returns a data frame with information such as library path, version, and dependencies. ```r pkg_status("MASS") ```