Skip to content

A Fresh Approach to R Package Installation

pak installs R packages from CRAN, Bioconductor, GitHub, URLs, 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")
#>  Updated metadata database: 2.37 MB in 2 files.                                
#>  Updating metadata database ... done                                           
#>                                                                                 
#> → Will install 11 packages.                                                     
#> → Will download 10 CRAN packages (3.64 MB), cached: 1 (916.78 kB).              
#> + cli         3.4.1 [bld][cmp][dl] (540.04 kB)                                  
#> + fansi       1.0.3 [bld][cmp][dl] (481.16 kB)                                  
#> + glue        1.6.2 [bld][cmp][dl] (106.51 kB)                                  
#> + lifecycle   1.0.2 [bld][dl] (102.18 kB)                                       
#> + magrittr    2.0.3 [bld][cmp][dl] (267.07 kB)                                  
#> + pillar      1.8.1 [bld][dl] (479.98 kB)                                       
#> + pkgconfig   2.0.3 [bld][dl] (6.08 kB)                                         
#> + rlang       1.0.6 [bld][cmp][dl] (742.51 kB)                                  
#> + tibble      3.1.8 [bld][cmp][dl] (672.34 kB)                                  
#> + utf8        1.2.2 [bld][cmp][dl] (240.33 kB)                                  
#> + vctrs       0.4.2 [bld][cmp]                                                  
#>  Getting 10 pkgs (3.64 MB), 1 (916.78 kB) cached                               
#>  Got glue 1.6.2 (source) (106.51 kB)                                           
#>  Got pkgconfig 2.0.3 (source) (6.08 kB)                                        
#>  Got cli 3.4.1 (source) (540.04 kB)                                            
#>  Got fansi 1.0.3 (source) (481.16 kB)                                          
#>  Got utf8 1.2.2 (source) (240.33 kB)                                           
#>  Got lifecycle 1.0.2 (source) (102.18 kB)                                      
#>  Got magrittr 2.0.3 (source) (267.07 kB)                                       
#>  Got rlang 1.0.6 (source) (742.51 kB)                                          
#>  Got pillar 1.8.1 (source) (479.98 kB)                                         
#>  Got tibble 3.1.8 (source) (672.34 kB)                                         
#>  Got vctrs 0.4.2 (source) (915.86 kB)                                          
#>  Building cli 3.4.1                                                            
#>  Building fansi 1.0.3                                                          
#>  Built fansi 1.0.3 (4.7s)                                                      
#>  Building glue 1.6.2                                                           
#>  Built glue 1.6.2 (1.7s)                                                       
#>  Building magrittr 2.0.3                                                       
#>  Built magrittr 2.0.3 (1.3s)                                                   
#>  Building pkgconfig 2.0.3                                                      
#>  Built pkgconfig 2.0.3 (886ms)                                                 
#>  Building rlang 1.0.6                                                          
#>  Built cli 3.4.1 (9.3s)                                                        
#>  Building utf8 1.2.2                                                           
#>  Built utf8 1.2.2 (4.1s)                                                       
#>  Installed cli 3.4.1  (55ms)                                                   
#>  Installed fansi 1.0.3  (30ms)                                                 
#>  Installed glue 1.6.2  (29ms)                                                  
#>  Installed magrittr 2.0.3  (31ms)                                              
#>  Installed pkgconfig 2.0.3  (25ms)                                             
#>  Installed utf8 1.2.2  (31ms)                                                  
#>  Built rlang 1.0.6 (13.4s)                                                     
#>  Installed rlang 1.0.6  (53ms)                                                 
#>  Building lifecycle 1.0.2                                                      
#>  Building vctrs 0.4.2                                                          
#>  Built lifecycle 1.0.2 (1.4s)                                                  
#>  Installed lifecycle 1.0.2  (27ms)                                             
#>  Built vctrs 0.4.2 (20.4s)                                                     
#>  Installed vctrs 0.4.2  (66ms)                                                 
#>  Building pillar 1.8.1                                                         
#>  Built pillar 1.8.1 (3.8s)                                                     
#>  Installed pillar 1.8.1  (36ms)                                                
#>  Building tibble 3.1.8                                                         
#>  Built tibble 3.1.8 (3.6s)                                                     
#>  Installed tibble 3.1.8  (56ms)                                                
#>  1 pkg + 10 deps: added 11, dld 11 (4.55 MB) [57.5s]                           

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 [bld][cmp] (GitHub: 8f6b813)                        
#> + vctrs  0.4.2 → 0.4.2.9000 [bld][cmp] (GitHub: 3f27175)                        
#>  No downloads are needed, 2 pkgs are cached                                    
#>  Got tibble 3.1.8.9002 (source) (1.34 MB)                                      
#>  Got vctrs 0.4.2.9000 (source) (2.09 MB)                                       
#>  Packaging vctrs 0.4.2.9000                                                    
#>  Packaged vctrs 0.4.2.9000 (947ms)                                             
#>  Building vctrs 0.4.2.9000                                                     
#>  Built vctrs 0.4.2.9000 (21s)                                                  
#>  Installed vctrs 0.4.2.9000 (github::r-lib/vctrs@3f27175) (67ms)               
#>  Packaging tibble 3.1.8.9002                                                   
#>  Packaged tibble 3.1.8.9002 (540ms)                                            
#>  Building tibble 3.1.8.9002                                                    
#>  Built tibble 3.1.8.9002 (3.4s)                                                
#>  Installed tibble 3.1.8.9002 (github::tidyverse/tibble@8f6b813) (31ms)         
#>  1 pkg + 10 deps: kept 9, upd 2, dld 2 (NA B) [28.7s]                          

Look up dependencies

pak::pkg_deps_tree("tibble")
#> tibble 3.1.8 [new][bld][cmp]                                                    
#> ├─fansi 1.0.3 [new][bld][cmp]                                                   
#> ├─lifecycle 1.0.2 [new][bld]                                                    
#> │ ├─glue 1.6.2 [new][bld][cmp]                                                  
#> │ └─rlang 1.0.6 [new][bld][cmp]                                                 
#> ├─magrittr 2.0.3 [new][bld][cmp]                                                
#> ├─pillar 1.8.1 [new][bld]                                                       
#> │ ├─cli 3.4.1 [new][bld][cmp]                                                   
#> │ ├─fansi                                                                       
#> │ ├─glue                                                                        
#> │ ├─lifecycle                                                                   
#> │ ├─rlang                                                                       
#> │ ├─utf8 1.2.2 [new][bld][cmp]                                                  
#> │ └─vctrs 0.4.2 [new][bld][cmp]                                                 
#> │   ├─cli                                                                       
#> │   ├─glue                                                                      
#> │   └─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 -> rlang                                              
#> tibble -> 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 [bld][cmp]                                                  
#>  No downloads are needed, 1 pkg is cached                                      
#>  Got cli 3.4.1 (source) (540.04 kB)                                            
#>  Packaging cli 3.4.1                                                           
#>  Packaged cli 3.4.1 (732ms)                                                    
#>  Building cli 3.4.1                                                            
#>  Built cli 3.4.1 (9.1s)                                                        
#>  Installed cli 3.4.1 (local) (41ms)                                            
#>  1 pkg: upd 1, dld 1 (540.04 kB) [10.3s]                                       

How do I … ?

Start with our our TLDR document 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.4.0 - R-devel
Linux aarch64 R 3.4.0 - R-devel
macOS High Sierra+ x86_64 R 3.4.0 - R-devel
macOS Big Sur+ aarch64 R 4.1.0 - R-devel
Windows x86_64 R 3.4.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