pak

A Fresh Approach to R Package Installation

lifecycle CRAN RStudio mirror downloads Codecov test coverage R-CMD-check

pak installs R packages from CRAN, Bioconductor, GitHub, URLs, git repositories, local files and directories. It is an alternative to install.packages() and devtools::install_github(). pak is fast, safe and convenient.

:rocket: Short tour

Install or update packages from CRAN or Bioconductor

pak::pkg_install("tibble")
#>  Loading metadata database ... done
#>
#> → Will install 11 packages.
#> → All 11 packages (7.48 MB) are cached.
#> + cli         3.4.1
#> + fansi       1.0.3
#> + glue        1.6.2
#> + lifecycle   1.0.3
#> + magrittr    2.0.3
#> + pillar      1.8.1
#> + pkgconfig   2.0.3
#> + rlang       1.0.6
#> + tibble      3.1.8
#> + utf8        1.2.2
#> + vctrs       0.5.1
#>  No downloads are needed, 11 pkgs (7.48 MB) are cached
#>  Installed cli 3.4.1  (68ms)
#>  Installed fansi 1.0.3  (78ms)
#>  Installed glue 1.6.2  (95ms)
#>  Installed lifecycle 1.0.3  (120ms)
#>  Installed magrittr 2.0.3  (126ms)
#>  Installed pkgconfig 2.0.3  (125ms)
#>  Installed pillar 1.8.1  (154ms)
#>  Installed rlang 1.0.6  (176ms)
#>  Installed tibble 3.1.8  (77ms)
#>  Installed utf8 1.2.2  (44ms)
#>  Installed vctrs 0.5.1  (35ms)
#>  1 pkg + 10 deps: added 11 [2.8s]

Install packages from GitHub

pak::pkg_install("tidyverse/tibble")
#>
#> → Will update 2 packages.
#> → All 2 packages (0 B) are cached.
#> + tibble 3.1.8 → 3.1.8.9002 👷🏾🔧 (GitHub: 37ec86a)
#> + vctrs  0.5.1 → 0.5.1.9000 👷🏼‍♂️🔧 (GitHub: 48794fd)
#>  No downloads are needed, 2 pkgs are cached
#>  Packaging vctrs 0.5.1.9000
#>  Packaged vctrs 0.5.1.9000 (1.5s)
#>  Building vctrs 0.5.1.9000
#>  Built vctrs 0.5.1.9000 (11s)
#>  Installed vctrs 0.5.1.9000 (github::r-lib/vctrs@48794fd) (36ms)
#>  Packaging tibble 3.1.8.9002
#>  Packaged tibble 3.1.8.9002 (525ms)
#>  Building tibble 3.1.8.9002
#>  Built tibble 3.1.8.9002 (3.1s)
#>  Installed tibble 3.1.8.9002 (github::tidyverse/tibble@37ec86a) (34ms)
#>  1 pkg + 10 deps: kept 9, upd 2 [18.9s]

Look up dependencies

pak::pkg_deps_tree("tibble")
#> tibble 3.1.8 
#> ├─fansi 1.0.3 
#> ├─lifecycle 1.0.3 
#> │ ├─cli 3.4.1 
#> │ ├─glue 1.6.2 
#> │ └─rlang 1.0.6 
#> ├─magrittr 2.0.3 
#> ├─pillar 1.8.1 
#> │ ├─cli
#> │ ├─fansi
#> │ ├─glue
#> │ ├─lifecycle
#> │ ├─rlang
#> │ ├─utf8 1.2.2 
#> │ └─vctrs 0.5.1 
#> │   ├─cli
#> │   ├─glue
#> │   ├─lifecycle
#> │   └─rlang
#> ├─pkgconfig 2.0.3 
#> ├─rlang
#> └─vctrs
#>
#> Key:   new

Explain dependencies

pak::pkg_deps_explain("tibble", "rlang")
#> tibble -> lifecycle -> rlang
#> tibble -> pillar -> lifecycle -> rlang
#> tibble -> pillar -> rlang
#> tibble -> pillar -> vctrs -> lifecycle -> rlang
#> tibble -> pillar -> vctrs -> rlang
#> tibble -> rlang
#> tibble -> vctrs -> lifecycle -> rlang
#> tibble -> vctrs -> rlang

Install a local package and its dependencies

pak::local_install("cli")
#>
#> → Will update 1 package.
#> → The package (0 B) is cached.
#> + cli 3.4.1 → 3.4.1 👷🏿🔧
#>  No downloads are needed, 1 pkg is cached
#>  Got cli 3.4.1 (source) (96 B)
#>  Packaging cli 3.4.1
#>  Packaged cli 3.4.1 (664ms)
#>  Building cli 3.4.1
#>  Built cli 3.4.1 (5s)
#>  Installed cli 3.4.1 (local) (42ms)
#>  1 pkg: upd 1, dld 1 (NA B) [6.4s]

How do I … ?

Start at Get Started with pak to solve specific issues.

FAQ

Check out the list of frequently asked questions.

Reference

The complete reference of pak functions is the most complete source of information about pak.

I have a(nother) question

Don’t hesitate to ask at the RStudio Community forum. Use the pak tag.

I would like to report a bug

Head to the pak issue tracker.

:sparkles: Features

:zap: Fast - parallel downloads and installation, caching, etc.

:safety_vest: Safe - dependency solver, system dependency solver, etc.

:convenience_store: Convenient - packages from multiple sources, time travel, etc.

See the complete list of awesome features.

:arrow_down: Installation

Pre-built binaries

Install a binary build of pak from our repository on GitHub:

install.packages("pak", repos = sprintf("https://r-lib.github.io/p/pak/stable/%s/%s/%s", .Platform$pkgType, R.Version()$os, R.Version()$arch))

This is supported for the following systems:

OS CPU R version
Linux x86_64 R 3.5.0 - R-devel
Linux aarch64 R 3.5.0 - R-devel
macOS High Sierra+ x86_64 R 3.5.0 - R-devel
macOS Big Sur+ aarch64 R 4.1.0 - R-devel
Windows x86_64 R 3.5.0 - R-devel

For macOS we only support the official CRAN R build. Other builds, e.g. Homebrew R, are not supported.

Install from CRAN

Install the released version of the package from CRAN as usual:

install.packages("pak")

This potentially needs a C compiler on platforms CRAN does not have binaries packages for.

Other platforms and nightly builds

See the installation page!

:blue_book: License

GPL-3 © RStudio