### Pak Package Installation Example Source: https://github.com/r-lib/pak/blob/main/man/chunks/sysreqs.md Demonstrates installing a binary package using pak and then loading it. This is typically used when installing from sources like the Posit Package Manager. ```r pak::pkg_install("RPostgres") library(RPostgres) ``` -------------------------------- ### Pak Package Installation Output Example Source: https://github.com/r-lib/pak/blob/main/man/chunks/sysreqs.md Example output from pak indicating that packages are cached and ready for installation. This output is shown before the actual installation process begins. ```text → Will install 17 packages. → All 17 packages (0 B) are cached. ``` -------------------------------- ### Print Install Summary (Plain) Source: https://github.com/r-lib/pak/blob/main/tests/testthat/_snaps/print.md Displays a plain text summary of package installation progress. Use this when rich text formatting is not supported or desired. ```R print_install_summary(d) ``` ```text v 3 deps: kept 1, upd 2, dld 1 (114.69 kB) [12.1s] ``` ```R print_install_summary(d) ``` ```text v 1 pkg + 3 deps: kept 1, upd 2, added 1, dld 1 (114.69 kB) [12.1s] ``` ```R print_install_summary(d) ``` ```text v 4 pkgs: kept 1, upd 2, added 1, dld 1 (114.69 kB) [12.1s] ``` ```R print_install_summary(d) ``` ```text v 4 pkgs: upd 2, added 2, dld 1 (114.69 kB) [12.1s] ``` ```R print_install_summary(d) ``` ```text v 4 pkgs: kept 2, added 2, dld 1 (114.69 kB) [12.1s] ``` -------------------------------- ### Install Package from GitHub Source: https://github.com/r-lib/pak/blob/main/README.md Install a package directly from a GitHub repository using the format 'username/repository'. ```r pak::pkg_install("tidyverse/tibble") ``` -------------------------------- ### Print Install Summary (Fancy) Source: https://github.com/r-lib/pak/blob/main/tests/testthat/_snaps/print.md Displays a colorized summary of package installation progress. Use this for enhanced readability in terminals that support ANSI color codes. ```R print_install_summary(d) ``` ```text ✔ 3 deps: kept 1, upd 2, dld 1 (114.69 kB) [12.1s] ``` ```R print_install_summary(d) ``` ```text ✔ 1 pkg + 3 deps: kept 1, upd 2, added 1, dld 1 (114.69 kB) [12.1s] ``` ```R print_install_summary(d) ``` ```text ✔ 4 pkgs: kept 1, upd 2, added 1, dld 1 (114.69 kB) [12.1s] ``` ```R print_install_summary(d) ``` ```text ✔ 4 pkgs: upd 2, added 2, dld 1 (114.69 kB) [12.1s] ``` ```R print_install_summary(d) ``` ```text ✔ 4 pkgs: kept 2, added 2, dld 1 (114.69 kB) [12.1s] ``` -------------------------------- ### Install pak from R-lib GitHub Repository Source: https://github.com/r-lib/pak/blob/main/README.md Install a pre-built binary of pak from the R-lib GitHub repository. This method is recommended for supported systems and R versions. ```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)) ``` -------------------------------- ### Install Local Package and Dependencies Source: https://github.com/r-lib/pak/blob/main/README.md Install a local R package along with its dependencies using `local_install`. Ensure the package directory is correctly specified. ```r pak::local_install("cli") ``` -------------------------------- ### List All Installed System Packages Source: https://github.com/r-lib/pak/blob/main/man/chunks/sysreqs.md Use `sysreqs_list_system_packages()` to get a cross-platform list of all installed system packages and their capabilities. This function helps in understanding the current system environment. ```r pak::sysreqs_list_system_packages() ``` -------------------------------- ### Install RPostgres Source Package Source: https://github.com/r-lib/pak/blob/main/man/chunks/sysreqs.md This command attempts to install the RPostgres package from source. If required system libraries are missing and sudo is not available, the installation will likely fail, as demonstrated in the accompanying output. ```r pak::pkg_install("RPostgres?source") ``` -------------------------------- ### Control build setup source execution Source: https://github.com/r-lib/pak/blob/main/src/library/pkgbuild/NEWS.md The `build_setup_source` function now considers both command-line build arguments and parameters like `vignettes` or `manual` when conditionally executing flag-dependent behaviors. ```R build_setup_source ``` -------------------------------- ### Format Inline Style with Code Source: https://github.com/r-lib/pak/blob/main/src/library/cli/NEWS.md Demonstrates how `{}` substitutions within inline styles are now formatted correctly. This example shows a URL being formatted as code. ```r {.code download({url})} ``` -------------------------------- ### Install R Package with System Dependencies Source: https://github.com/r-lib/pak/blob/main/man/chunks/sysreqs.md Installs an R package and automatically handles its system dependencies. This function is intended to be run by a superuser on a supported platform to ensure all necessary system libraries are installed. ```r pak::pkg_install("RPostgres") ``` -------------------------------- ### Format Inline Style Values Source: https://github.com/r-lib/pak/blob/main/src/library/cli/NEWS.md Demonstrates how `{}` substitutions within inline styles are now formatted correctly. This example shows a value formatted with a prefix and suffix. ```r {.val pre-{x}-post} ``` -------------------------------- ### Install or Update Package from CRAN/Bioconductor Source: https://github.com/r-lib/pak/blob/main/README.md Use `pkg_install` to install or update a package from CRAN or Bioconductor. Ensure the package name is correctly specified. ```r pak::pkg_install("tibble") ``` -------------------------------- ### Style Code with Curly Braces Substitution Source: https://github.com/r-lib/pak/blob/main/src/library/cli/NEWS.md Expressions starting and ending with `{}` are now styled correctly. This example shows how to style a code expression with variable substitutions. ```r {.code {var1} + {var2}} ``` -------------------------------- ### R Error Backtrace Example Source: https://github.com/r-lib/pak/blob/main/man/chunks/sysreqs.md This is an example of a backtrace from an R subprocess, showing the call stack leading to an error. It is useful for debugging failed package installations. ```r 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 workers = 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 ``` -------------------------------- ### Install pak from CRAN Source: https://github.com/r-lib/pak/blob/main/README.md Install the released version of the pak package from CRAN using the standard `install.packages` function. This may require a C compiler on some platforms. ```r install.packages("pak") ``` -------------------------------- ### List Supported Platforms for System Requirements Source: https://github.com/r-lib/pak/blob/main/man/chunks/sysreqs.md Call this function to see all platforms that pak supports for managing system requirements. It returns a data frame detailing OS, distribution, and commands for updates and installations. ```r pak::sysreqs_platforms() ``` -------------------------------- ### Configure build to never clean DESCRIPTION option Source: https://github.com/r-lib/pak/blob/main/src/library/pkgbuild/NEWS.md Use the `Config/build/never-clean` DESCRIPTION option to prevent `--preclean` from being added to `R CMD INSTALL`. This is useful when header files have changed. ```R Config/build/never-clean ``` -------------------------------- ### Check Installed System Requirements Source: https://github.com/r-lib/pak/blob/main/man/chunks/sysreqs.md The `sysreqs_check_installed()` function checks if all system requirements are installed for the R packages in your library. It returns a data frame indicating the status of each system package. ```APIDOC ## Function: sysreqs_check_installed() ### Description Checks if system requirements for R packages are installed. ### Usage ```r pak::sysreqs_check_installed() ``` ### Details This function queries the system to determine which system packages are installed and whether they meet the requirements of the installed R packages. The output is a data frame with columns for 'system package', 'installed' status, and 'required by' R packages. ``` -------------------------------- ### Get Keyring Password using Environment Backend Source: https://github.com/r-lib/pak/blob/main/tests/testthat/_snaps/auth.md Retrieves a password for a given URL using the environment keyring backend. This is typically used after the password has been set. ```R pw <- repo_auth_key_get_internal(url) ``` -------------------------------- ### Control cleanup of inst/doc Source: https://github.com/r-lib/pak/blob/main/src/library/pkgbuild/NEWS.md By default, `pkgbuild::build()` will not clean up `inst/doc` if the `Config/build/clean-inst-doc` entry in `DESCRIPTION` is set to `FALSE`. ```R Config/build/clean-inst-doc ``` -------------------------------- ### Demo New Spinners in cli Source: https://github.com/r-lib/pak/blob/main/src/library/cli/NEWS.md Run this code to demo the 20 new spinners added to the cli package. Some spinners require UTF-8 and emoji support. ```r new <- c("dots13", "dots8Bit", "sand", "material", "weather", "christmas", "grenade", "point", "layer", "betaWave", "fingerDance", "fistBump", "soccerHeader", "mindblown", "speaker", "orangePulse", "bluePulse", "orangeBluePulse", "timeTravel", "aesthetic", "growVeriticalDotsLR", "growVeriticalDotsRL", "growVeriticalDotsLL", "growVeriticalDotsRR") demo_spinners(new) ``` -------------------------------- ### Configure build to use extra source files Source: https://github.com/r-lib/pak/blob/main/src/library/pkgbuild/NEWS.md The `Config/build/extra-sources` DESCRIPTION option makes pkgbuild aware of additional source files to consider in `needs_compile()`. ```R Config/build/extra-sources ``` -------------------------------- ### Check File Keyring Backend Existence Source: https://github.com/r-lib/pak/blob/main/tests/testthat/_snaps/auth.md Verifies if the default file-based keyring backend exists. If not, it indicates that `repo_auth_unlock()` needs to be called to create it. ```R check_keyring_backend(keyring::default_backend()) ``` -------------------------------- ### Create Default File Keyring Source: https://github.com/r-lib/pak/blob/main/tests/testthat/_snaps/auth.md Initializes and creates the default file-based keyring when it does not exist. This function is typically called via `repo_auth_unlock()`. ```R repo_auth_unlock_internal(password = "secret") ``` -------------------------------- ### Get correct Rtools version Source: https://github.com/r-lib/pak/blob/main/src/library/pkgbuild/NEWS.md The `rtools_needed` function now returns the correct version instead of 'custom'. ```R rtools_needed ``` -------------------------------- ### Fix Missing System Requirements Source: https://github.com/r-lib/pak/blob/main/man/chunks/sysreqs.md The `sysreqs_fix_installed()` function attempts to install any missing system requirements identified by `sysreqs_check_installed()`. ```APIDOC ## Function: sysreqs_fix_installed() ### Description Installs missing system requirements for R packages. ### Usage ```r pak::sysreqs_fix_installed() ``` ### Details This function automates the process of installing system dependencies that are not currently met. It is a convenient way to ensure all necessary system libraries are in place before building or running R packages. ``` -------------------------------- ### ps_boot_time() Source: https://github.com/r-lib/pak/blob/main/src/library/ps/inst/internals.md Retrieves the system's boot time. ```APIDOC ## ps_boot_time() ### Description Returns the timestamp when the system was last booted. ### Method GET (conceptual) ### Endpoint /boot_time ### Parameters None ### Request Example None ### Response #### Success Response (200) - **boot_time** (string) - The system boot time in ISO 8601 format. ### Response Example ```json { "boot_time": "2023-10-27T10:00:00Z" } ``` ``` -------------------------------- ### Configure build to run bootstrap script Source: https://github.com/r-lib/pak/blob/main/src/library/pkgbuild/NEWS.md Set the `Config/build/bootstrap` DESCRIPTION option to `TRUE` to execute `Rscript bootstrap.R` in the package root before building the source package. ```R Config/build/bootstrap ``` -------------------------------- ### Extract Packages from Matched System Requirements Source: https://github.com/r-lib/pak/blob/main/man/chunks/sysreqs.md Access the 'packages' field from the result of `sysreqs_db_match()` to get a list of package names for the matched system requirements. ```r sq[[1]]$packages ``` -------------------------------- ### ps() Source: https://github.com/r-lib/pak/blob/main/src/library/ps/inst/internals.md Retrieves information about running processes. ```APIDOC ## ps() ### Description Retrieves information about running processes on the system. ### Method GET (conceptual) ### Endpoint / ### Parameters None ### Request Example None ### Response #### Success Response (200) - **process_list** (array) - A list of process objects, each containing detailed information about a running process. ### Response Example ```json { "process_list": [ { "pid": 123, "name": "systemd", "status": "running", "cpu_times": { "user": 0.1, "system": 0.2 }, "memory_info": { "rss": 1024, "vms": 2048 } } ] } ``` ``` -------------------------------- ### Match System Requirements for a Specific Platform Source: https://github.com/r-lib/pak/blob/main/man/chunks/sysreqs.md Query system requirements for a specific operating system and version, such as 'redhat-9', using `sysreqs_db_match()` by providing the platform as a second argument. ```r sqrhel9 <- pak::sysreqs_db_match("Needs libcurl and also Java.", "redhat-9") sqrhel9 ``` -------------------------------- ### Set Keyring Password using Environment Backend Source: https://github.com/r-lib/pak/blob/main/tests/testthat/_snaps/auth.md Sets a password for a given URL using the environment keyring backend. This is useful for non-interactive environments. ```R repo_auth_key_set_internal(url, "secret") ``` -------------------------------- ### Session Credential for AES Key Source: https://github.com/r-lib/pak/blob/main/src/library/keyring/inst/development-notes.md This is an example of a base64 encoded AES key stored in a session credential. This key is used for encrypting and decrypting items within an unlocked keyring. ```text JvL7srqc0X1vVnqbSayFnIkJZoe2xMOWoDh+aBR9DJc= ``` -------------------------------- ### Unlock Keyring with Environment Backend Source: https://github.com/r-lib/pak/blob/main/tests/testthat/_snaps/auth.md Attempts to unlock the keyring using the environment backend. If the keyring is already unlocked, it reports that. ```R repo_auth_unlock_internal("pass") ``` -------------------------------- ### Match System Requirements from Text Source: https://github.com/r-lib/pak/blob/main/man/chunks/sysreqs.md Use `sysreqs_db_match()` to find system requirements for a given text string. This function helps identify necessary packages based on descriptions like 'Needs libcurl and also Java.' ```r sq <- pak::sysreqs_db_match("Needs libcurl and also Java.") sq ``` -------------------------------- ### Explain Package Dependencies Source: https://github.com/r-lib/pak/blob/main/README.md Use `pkg_deps_explain` to understand the dependencies between two specified packages. ```r pak::pkg_deps_explain("tibble", "rlang") ``` -------------------------------- ### Configure Rtools40 path for R 4.2 Source: https://github.com/r-lib/pak/blob/main/src/library/pkgbuild/NEWS.md To make Rtools40 work with R 4.2.x, R 4.1.x, and R 4.0.x, ensure the PATH includes both `${RTOOLS40_HOME}/usr/bin` and `${RTOOLS40_HOME}/ucrt64/bin`. The `.Renviron` file should be updated accordingly. ```R PATH="${RTOOLS40_HOME}\usr\bin;${RTOOLS40_HOME}\ucrt64\bin;${PATH}" ``` -------------------------------- ### Stop for build warnings Source: https://github.com/r-lib/pak/blob/main/src/library/pkgbuild/NEWS.md Set the `pkg.build_stop_for_warnings` option to `TRUE` or the `PKG_BUILD_STOP_FOR_WARNINGS` environment variable to `true` to turn `R CMD build` warnings into errors. ```R pkg.build_stop_for_warnings ``` ```R PKG_BUILD_STOP_FOR_WARNINGS ``` -------------------------------- ### Check System Support Source: https://github.com/r-lib/pak/blob/main/man/chunks/sysreqs.md Use this function to determine if your current system is supported by pak for managing system requirements. It returns a boolean value. ```r pak::sysreqs_is_supported() ``` -------------------------------- ### signals() Source: https://github.com/r-lib/pak/blob/main/src/library/ps/inst/internals.md Lists available signals that can be sent to processes. ```APIDOC ## signals() ### Description Provides a list of all valid signals that can be sent to processes on the system. ### Method GET (conceptual) ### Endpoint /signals ### Parameters None ### Request Example None ### Response #### Success Response (200) - **signals** (object) - An object where keys are signal names and values are their corresponding integer numbers. ### Response Example ```json { "signals": { "SIGHUP": 1, "SIGINT": 2, "SIGQUIT": 3 } } ``` ``` -------------------------------- ### Styled Lists Source: https://github.com/r-lib/pak/blob/main/src/library/cli/NEWS.md Functions for creating styled definition lists (`cli_dl`) and list items (`cli_li`). Labels within these lists can now be styled. ```r cli_dl() ``` ```r cli_li() ``` -------------------------------- ### with_process_cleanup() Source: https://github.com/r-lib/pak/blob/main/src/library/ps/inst/internals.md Manages process cleanup within a specified context. ```APIDOC ## with_process_cleanup(cleanup_function) ### Description Provides a context manager for performing process cleanup operations. It ensures that cleanup actions are executed even if errors occur. ### Method Context Manager (conceptual) ### Endpoint N/A ### Parameters #### Arguments - **cleanup_function** (function) - Required - The function to execute for cleanup. ### Request Example ```python with with_process_cleanup(my_cleanup_logic): # Perform operations that might require cleanup pass ``` ### Response N/A (This is a programmatic construct, not an API endpoint with request/response) ``` -------------------------------- ### Control build tool check messages Source: https://github.com/r-lib/pak/blob/main/src/library/pkgbuild/NEWS.md The `check_build_tools()` function now has a `quiet` argument to control message display. Messages are suppressed when `check_build_tools()` is called internally by other pkgbuild functions. ```R check_build_tools() ```