Skip to content

A Fresh Approach to R Package Installation

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.

🚀 Short tour

Install or update packages from CRAN or Bioconductor

pak::pkg_install("tibble")
#>  Loading metadata database ... done                                            
#>                                                                                 
#> → Will install 11 packages.                                                     
#> → Will download 11 CRAN packages (4.52 MB).                                     
#> + cli         3.6.2 [bld][cmp][dl] (569.77 kB)                                  
#> + fansi       1.0.6 [bld][cmp][dl] (482.48 kB)                                  
#> + glue        1.7.0 [bld][cmp][dl] (105.42 kB)                                  
#> + lifecycle   1.0.4 [bld][dl] (107.66 kB)                                       
#> + magrittr    2.0.3 [bld][cmp][dl] (267.07 kB)                                  
#> + pillar      1.9.0 [bld][dl] (444.53 kB)                                       
#> + pkgconfig   2.0.3 [bld][dl] (6.08 kB)                                         
#> + rlang       1.1.3 [bld][cmp][dl] (763.76 kB)                                  
#> + tibble      3.2.1 [bld][cmp][dl] (565.98 kB)                                  
#> + utf8        1.2.4 [bld][cmp][dl] (241.08 kB)                                  
#> + vctrs       0.6.5 [bld][cmp][dl] (969.07 kB)                                  
#>                                                                                 
#>  Getting 11 pkgs (4.52 MB)                                                     
#>  Got pkgconfig 2.0.3 (source) (6.08 kB)                                        
#>  Got glue 1.7.0 (source) (105.42 kB)                                           
#>  Got fansi 1.0.6 (source) (482.48 kB)                                          
#>  Got cli 3.6.2 (source) (569.77 kB)                                            
#>  Got tibble 3.2.1 (source) (565.98 kB)                                         
#>  Got lifecycle 1.0.4 (source) (107.66 kB)                                      
#>  Got utf8 1.2.4 (source) (241.08 kB)                                           
#>  Got pillar 1.9.0 (source) (444.53 kB)                                         
#>  Got rlang 1.1.3 (source) (763.76 kB)                                          
#>  Got magrittr 2.0.3 (source) (267.07 kB)                                       
#>  Got vctrs 0.6.5 (source) (969.07 kB)                                          
#>  Building cli 3.6.2                                                            
#>  Building fansi 1.0.6                                                          
#>  Building glue 1.7.0                                                           
#>  Building magrittr 2.0.3                                                       
#>  Built magrittr 2.0.3 (2s)                                                     
#>  Building pkgconfig 2.0.3                                                      
#>  Built glue 1.7.0 (2.7s)                                                       
#>  Building rlang 1.1.3                                                          
#>  Built pkgconfig 2.0.3 (1.3s)                                                  
#>  Building utf8 1.2.4                                                           
#>  Built fansi 1.0.6 (6.4s)                                                      
#>  Installed fansi 1.0.6  (43ms)                                                 
#>  Installed glue 1.7.0  (37ms)                                                  
#>  Installed magrittr 2.0.3  (38ms)                                              
#>  Installed pkgconfig 2.0.3  (29ms)                                             
#>  Built utf8 1.2.4 (4.9s)                                                       
#>  Installed utf8 1.2.4  (35ms)                                                  
#>  Built cli 3.6.2 (12s)                                                         
#>  Installed cli 3.6.2  (1s)                                                     
#>  Built rlang 1.1.3 (12.7s)                                                     
#>  Installed rlang 1.1.3  (1.1s)                                                 
#>  Building lifecycle 1.0.4                                                      
#>  Built lifecycle 1.0.4 (1.4s)                                                  
#>  Installed lifecycle 1.0.4  (1s)                                               
#>  Building vctrs 0.6.5                                                          
#>  Built vctrs 0.6.5 (16s)                                                       
#>  Installed vctrs 0.6.5  (48ms)                                                 
#>  Building pillar 1.9.0                                                         
#>  Built pillar 1.9.0 (3.3s)                                                     
#>  Installed pillar 1.9.0  (1s)                                                  
#>  Building tibble 3.2.1                                                         
#>  Built tibble 3.2.1 (3s)                                                       
#>  Installed tibble 3.2.1  (1s)                                                  
#>  1 pkg + 10 deps: added 11, dld 11 (4.52 MB) [50.5s]                           

Install packages from GitHub

pak::pkg_install("tidyverse/tibble")
#>                                                                                 
#> → Will update 1 package.                                                        
#> → The package (0 B) is cached.                                                  
#> + tibble 3.2.1 → 3.2.1.9017 [bld][cmp] (GitHub: b7a8b70)                        
#>                                                                                 
#>  No downloads are needed, 1 pkg is cached                                      
#>  Got tibble 3.2.1.9017 (source) (5.25 MB)                                      
#>  Packaging tibble 3.2.1.9017                                                   
#>  Packaged tibble 3.2.1.9017 (1.1s)                                             
#>  Building tibble 3.2.1.9017                                                    
#>  Built tibble 3.2.1.9017 (2.8s)                                                
#>  Installed tibble 3.2.1.9017 (github::tidyverse/tibble@b7a8b70) (1s)           
#>  1 pkg + 10 deps: kept 10, upd 1, dld 1 (NA B) [9.5s]                          

Look up dependencies

pak::pkg_deps_tree("tibble")
#> tibble 3.2.1 [new][bld][cmp]                                                    
#> ├─fansi 1.0.6 [new][bld][cmp]                                                   
#> ├─lifecycle 1.0.4 [new][bld]                                                    
#> │ ├─cli 3.6.2 [new][bld][cmp]                                                   
#> │ ├─glue 1.7.0 [new][bld][cmp]                                                  
#> │ └─rlang 1.1.3 [new][bld][cmp]                                                 
#> ├─magrittr 2.0.3 [new][bld][cmp]                                                
#> ├─pillar 1.9.0 [new][bld]                                                       
#> │ ├─cli                                                                         
#> │ ├─fansi                                                                       
#> │ ├─glue                                                                        
#> │ ├─lifecycle                                                                   
#> │ ├─rlang                                                                       
#> │ ├─utf8 1.2.4 [new][bld][cmp]                                                  
#> │ └─vctrs 0.6.5 [new][bld][cmp]                                                 
#> │   ├─cli                                                                       
#> │   ├─glue                                                                      
#> │   ├─lifecycle                                                                 
#> │   └─rlang                                                                     
#> ├─pkgconfig 2.0.3 [new][bld]                                                    
#> ├─rlang                                                                         
#> └─vctrs                                                                         
#>                                                                                 
#> Key:  [new] new | [bld] build | [cmp] compile                                   

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.6.2 → 3.6.2 [bld][cmp]                                                  
#>                                                                                 
#>  No downloads are needed, 1 pkg is cached                                      
#>  Got cli 3.6.2 (source) (569.77 kB)                                            
#>  Packaging cli 3.6.2                                                           
#>  Packaged cli 3.6.2 (769ms)                                                    
#>  Building cli 3.6.2                                                            
#>  Built cli 3.6.2 (7.8s)                                                        
#>  Installed cli 3.6.2 (local) (1s)                                              
#>  1 pkg: upd 1, dld 1 (569.77 kB) [10.4s]                                       

How do I … ?

Start at Get Started with pak to solve specific issues.

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.

Features

Fast - parallel downloads and installation, caching, etc.

🦺 Safe - dependency solver, system dependency solver, etc.

🏪 Convenient - packages from multiple sources, time travel, etc.

See the complete list of awesome features.

⬇️ 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:

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

Other platforms and nightly builds

See the installation page!

📘 License

GPL-3 © RStudio