Skip to content

Please look at this before asking questions.

Package installation

How do I reinstall a package?

pak does not reinstall a package, if the same version is already installed. Sometimes you still want a reinstall, e.g. to fix a broken installation. In this case you can delete the package and then install it, or use the ?reinstall parameter:

pak::pkg_install("tibble")

#>                                                                                 
#> → Will install 13 packages.                                                     
#> → All 13 packages (7.45 MB) are cached.                                         
#> + cli         3.3.0                                                             
#> + crayon      1.5.1                                                             
#> + ellipsis    0.3.2                                                             
#> + fansi       1.0.3                                                             
#> + glue        1.6.2                                                             
#> + lifecycle   1.0.1                                                             
#> + magrittr    2.0.3                                                             
#> + pillar      1.7.0                                                             
#> + pkgconfig   2.0.3                                                             
#> + rlang       1.0.2                                                             
#> + tibble      3.1.7                                                             
#> + utf8        1.2.2                                                             
#> + vctrs       0.4.1                                                             
#>  No downloads are needed, 13 pkgs (7.45 MB) are cached                         
#>  Got ellipsis 0.3.2 (aarch64-apple-darwin20) (38.65 kB)                        
#>  Got lifecycle 1.0.1 (aarch64-apple-darwin20) (107.55 kB)                      
#>  Got crayon 1.5.1 (aarch64-apple-darwin20) (158.62 kB)                         
#>  Got glue 1.6.2 (aarch64-apple-darwin20) (154.64 kB)                           
#>  Got pkgconfig 2.0.3 (aarch64-apple-darwin20) (17.70 kB)                       
#>  Got utf8 1.2.2 (aarch64-apple-darwin20) (209.24 kB)                           
#>  Got magrittr 2.0.3 (aarch64-apple-darwin20) (231.25 kB)                       
#>  Got fansi 1.0.3 (aarch64-apple-darwin20) (379.23 kB)                          
#>  Got cli 3.3.0 (aarch64-apple-darwin20) (1.17 MB)                              
#>  Got pillar 1.7.0 (aarch64-apple-darwin20) (744.33 kB)                         
#>  Got tibble 3.1.7 (aarch64-apple-darwin20) (723.61 kB)                         
#>  Got vctrs 0.4.1 (aarch64-apple-darwin20) (1.76 MB)                            
#>  Got rlang 1.0.2 (aarch64-apple-darwin20) (1.79 MB)                            
#>  Installed cli 3.3.0  (66ms)                                                   
#>  Installed crayon 1.5.1  (75ms)                                                
#>  Installed ellipsis 0.3.2  (85ms)                                              
#>  Installed fansi 1.0.3  (109ms)                                                
#>  Installed glue 1.6.2  (117ms)                                                 
#>  Installed lifecycle 1.0.1  (126ms)                                            
#>  Installed magrittr 2.0.3  (133ms)                                             
#>  Installed pillar 1.7.0  (151ms)                                               
#>  Installed pkgconfig 2.0.3  (36ms)                                             
#>  Installed rlang 1.0.2  (56ms)                                                 
#>  Installed tibble 3.1.7  (40ms)                                                
#>  Installed utf8 1.2.2  (38ms)                                                  
#>  Installed vctrs 0.4.1  (28ms)                                                 
#>  1 pkg + 12 deps: added 13, dld 13 (7.48 MB) [4.7s]                            

pak::pkg_install("tibble?reinstall")

#>                                                                                 
#> → Will install 1 package.                                                       
#> → The package (724.32 kB) is cached.                                            
#> + tibble   3.1.7                                                                
#>  No downloads are needed, 1 pkg (724.32 kB) is cached                          
#>  Installed tibble 3.1.7  (27ms)                                                
#>  1 pkg + 12 deps: kept 11, added 1 [746ms]                                     

How do I install a package from source?

To force the installation of a source package (instead of a binary package), use the ?source parameter:

pak::pkg_install("tibble?source")

#>                                                                                 
#> → Will install 1 package.                                                       
#> → The package (672.34 kB) is cached.                                            
#> + tibble   3.1.7 👷🏼🔧                                                            
#>  No downloads are needed, 1 pkg (672.34 kB) is cached                          
#>  Got tibble 3.1.7 (source) (674.87 kB)                                         
#>  Building tibble 3.1.7                                                         
#>  Built tibble 3.1.7 (2.8s)                                                     
#>  Installed tibble 3.1.7  (26ms)                                                
#>  1 pkg + 12 deps: kept 11, added 1, dld 1 (674.87 kB) [8.2s]                   

How do I ignore an optional dependency?

pak::pkg_install(
  c("tibble", "DiagrammeR=?ignore", "formattable=?ignore"),
  dependencies = TRUE
)

#> → Will install 84 packages.                                                     
#> → Will download 67 CRAN packages (59.08 MB), cached: 17 (16.78 MB).             
#> + askpass        1.1     ⬇ (22.91 kB)                                           
#> + base64enc      0.1-3   ⬇ (33.62 kB)                                           
#> + bench          1.1.2   ⬇ (351.52 kB)                                          
#> + bit            4.0.5   ⬇ (1.23 MB)                                            
#> + bit64          4.0.5   ⬇ (560.61 kB)                                          
#> + blob           1.2.3   ⬇ (45.90 kB)                                           
#> + brio           1.1.3   ⬇ (43.84 kB)                                           
#> + bslib          0.4.1   ⬇ (4.79 MB)                                            
#> + cachem         1.0.6   ⬇ (67.65 kB)                                           
#> + callr          3.7.3                                                          
#> + cli            3.4.1                                                          
#> + colorspace     2.0-3   ⬇ (2.62 MB)                                            
#> + covr           3.6.1   ⬇ (327.92 kB)                                          
#> + crayon         1.5.2   ⬇ (161.50 kB)                                          
#> + curl           4.3.3   ⬇ (756.97 kB)                                          
#> + desc           1.4.2   ⬇ (326.69 kB)                                          
#> + diffobj        0.3.5   ⬇ (1.01 MB)                                            
#> + digest         0.6.30                                                         
#> + dplyr          1.0.10  ⬇ (1.33 MB)                                            
#> + ellipsis       0.3.2   ⬇ (38.65 kB)                                           
#> + evaluate       0.18    ⬇ (77.93 kB)                                           
#> + fansi          1.0.3   ⬇ (379.23 kB)                                          
#> + farver         2.1.1   ⬇ (1.93 MB)                                            
#> + fastmap        1.1.0   ⬇ (178.21 kB)                                          
#> + fs             1.5.2   ⬇ (589.90 kB)                                          
#> + generics       0.1.3   ⬇ (78.24 kB)                                           
#> + ggplot2        3.4.0   ⬇ (4.21 MB)                                            
#> + glue           1.6.2   ⬇ (154.64 kB)                                          
#> + gtable         0.3.1   ⬇ (159.19 kB)                                          
#> + highr          0.9     ⬇ (38.77 kB)                                           
#> + hms            1.1.2   ⬇ (97.47 kB)                                           
#> + htmltools      0.5.3   ⬇ (341.24 kB)                                          
#> + httr           1.4.4   ⬇ (504.65 kB)                                          
#> + isoband        0.2.6   ⬇ (3.29 MB)                                            
#> + jquerylib      0.1.4   ⬇ (526.05 kB)                                          
#> + jsonlite       1.8.3                                                          
#> + knitr          1.41                                                           
#> + labeling       0.4.2   ⬇ (60.13 kB)                                           
#> + lazyeval       0.2.2   ⬇ (159.69 kB)                                          
#> + lifecycle      1.0.3                                                          
#> + lubridate      1.9.0   ⬇ (977.16 kB)                                          
#> + magrittr       2.0.3   ⬇ (231.25 kB)                                          
#> + memoise        2.0.1   ⬇ (47.93 kB)                                           
#> + mime           0.12    ⬇ (36.16 kB)                                           
#> + mockr          0.2.0   ⬇ (43.30 kB)                                           
#> + munsell        0.5.0   ⬇ (241.65 kB)                                          
#> + nycflights13   1.0.2   ⬇ (4.50 MB)                                            
#> + openssl        2.0.4                                                          
#> + pillar         1.8.1   ⬇ (676.78 kB)                                          
#> + pkgbuild       1.3.1   ⬇ (143.57 kB)                                          
#> + pkgconfig      2.0.3   ⬇ (17.70 kB)                                           
#> + pkgload        1.3.2                                                          
#> + praise         1.0.0   ⬇ (16.08 kB)                                           
#> + prettyunits    1.1.1   ⬇ (34.70 kB)                                           
#> + processx       3.8.0                                                          
#> + profmem        0.6.0   ⬇ (51.49 kB)                                           
#> + ps             1.7.2                                                          
#> + purrr          0.3.5   ⬇ (426.25 kB)                                          
#> + R6             2.5.1   ⬇ (82.52 kB)                                           
#> + rappdirs       0.3.3   ⬇ (46.80 kB)                                           
#> + RColorBrewer   1.1-3   ⬇ (52.95 kB)                                           
#> + rematch2       2.1.2   ⬇ (43.89 kB)                                           
#> + rex            1.2.1   ⬇ (122.38 kB)                                          
#> + rlang          1.0.6   ⬇ (1.83 MB)                                            
#> + rmarkdown      2.18                                                           
#> + rprojroot      2.0.3   ⬇ (100.20 kB)                                          
#> + sass           0.4.3                                                          
#> + scales         1.2.1   ⬇ (610.06 kB)                                          
#> + stringi        1.7.8   ⬇ (14.52 MB)                                           
#> + stringr        1.4.1   ⬇ (214.01 kB)                                          
#> + sys            3.4.1                                                          
#> + testthat       3.1.5   ⬇ (2.93 MB)                                            
#> + tibble         3.1.8   ⬇ (724.32 kB)                                          
#> + tidyr          1.2.1   ⬇ (1.01 MB)                                            
#> + tidyselect     1.2.0                                                          
#> + timechange     0.1.1   ⬇ (882.60 kB)                                          
#> + tinytex        0.42    ⬇ (133.32 kB)                                          
#> + utf8           1.2.2   ⬇ (209.24 kB)                                          
#> + vctrs          0.5.1                                                          
#> + viridisLite    0.4.1   ⬇ (1.30 MB)                                            
#> + waldo          0.4.0   ⬇ (99.88 kB)                                           
#> + withr          2.5.0   ⬇ (229.48 kB)                                          
#> + xfun           0.35                                                           
#> + yaml           2.3.6                                                          
#>  Getting 67 pkgs (59.08 MB), 17 (16.78 MB) cached                              
#>  Got askpass 1.1 (aarch64-apple-darwin20) (22.91 kB)                           
#>  Got base64enc 0.1-3 (aarch64-apple-darwin20) (33.62 kB)                       
#>  Got RColorBrewer 1.1-3 (aarch64-apple-darwin20) (52.95 kB)                    
#>  Got R6 2.5.1 (aarch64-apple-darwin20) (82.52 kB)                              
#>  Got bench 1.1.2 (aarch64-apple-darwin20) (351.52 kB)                          
#>  Got bit64 4.0.5 (aarch64-apple-darwin20) (560.61 kB)                          
#>  Got curl 4.3.3 (aarch64-apple-darwin20) (756.97 kB)                           
#>  Got generics 0.1.3 (aarch64-apple-darwin20) (78.24 kB)                        
#>  Got covr 3.6.1 (aarch64-apple-darwin20) (327.92 kB)                           
#>  Got desc 1.4.2 (aarch64-apple-darwin20) (326.69 kB)                           
#>  Got ellipsis 0.3.2 (aarch64-apple-darwin20) (38.65 kB)                        
#>  Got highr 0.9 (aarch64-apple-darwin20) (38.77 kB)                             
#>  Got cachem 1.0.6 (aarch64-apple-darwin20) (67.65 kB)                          
#>  Got lifecycle 1.0.3 (aarch64-apple-darwin20) (122.95 kB)                      
#>  Got evaluate 0.18 (aarch64-apple-darwin20) (77.93 kB)                         
#>  Got farver 2.1.1 (aarch64-apple-darwin20) (1.93 MB)                           
#>  Got mime 0.12 (aarch64-apple-darwin20) (36.16 kB)                             
#>  Got jquerylib 0.1.4 (aarch64-apple-darwin20) (526.05 kB)                      
#>  Got pkgconfig 2.0.3 (aarch64-apple-darwin20) (17.70 kB)                       
#>  Got prettyunits 1.1.1 (aarch64-apple-darwin20) (34.70 kB)                     
#>  Got fastmap 1.1.0 (aarch64-apple-darwin20) (178.21 kB)                        
#>  Got bslib 0.4.1 (aarch64-apple-darwin20) (4.79 MB)                            
#>  Got pillar 1.8.1 (aarch64-apple-darwin20) (676.78 kB)                         
#>  Got magrittr 2.0.3 (aarch64-apple-darwin20) (231.25 kB)                       
#>  Got rematch2 2.1.2 (aarch64-apple-darwin20) (43.89 kB)                        
#>  Got purrr 0.3.5 (aarch64-apple-darwin20) (426.25 kB)                          
#>  Got munsell 0.5.0 (aarch64-apple-darwin20) (241.65 kB)                        
#>  Got diffobj 0.3.5 (aarch64-apple-darwin20) (1.01 MB)                          
#>  Got utf8 1.2.2 (aarch64-apple-darwin20) (209.24 kB)                           
#>  Got blob 1.2.3 (aarch64-apple-darwin20) (45.90 kB)                            
#>  Got viridisLite 0.4.1 (aarch64-apple-darwin20) (1.30 MB)                      
#>  Got scales 1.2.1 (aarch64-apple-darwin20) (610.06 kB)                         
#>  Got tidyr 1.2.1 (aarch64-apple-darwin20) (1.01 MB)                            
#>  Got hms 1.1.2 (aarch64-apple-darwin20) (97.47 kB)                             
#>  Got testthat 3.1.5 (aarch64-apple-darwin20) (2.93 MB)                         
#>  Got labeling 0.4.2 (aarch64-apple-darwin20) (60.13 kB)                        
#>  Got fansi 1.0.3 (aarch64-apple-darwin20) (379.23 kB)                          
#>  Got timechange 0.1.1 (aarch64-apple-darwin20) (882.60 kB)                     
#>  Got httr 1.4.4 (aarch64-apple-darwin20) (504.65 kB)                           
#>  Got isoband 0.2.6 (aarch64-apple-darwin20) (3.29 MB)                          
#>  Got profmem 0.6.0 (aarch64-apple-darwin20) (51.49 kB)                         
#>  Got rlang 1.0.6 (aarch64-apple-darwin20) (1.83 MB)                            
#>  Got fs 1.5.2 (aarch64-apple-darwin20) (589.90 kB)                             
#>  Got mockr 0.2.0 (aarch64-apple-darwin20) (43.30 kB)                           
#>  Got colorspace 2.0-3 (aarch64-apple-darwin20) (2.62 MB)                       
#>  Got rex 1.2.1 (aarch64-apple-darwin20) (122.38 kB)                            
#>  Got tinytex 0.42 (aarch64-apple-darwin20) (133.32 kB)                         
#>  Got crayon 1.5.2 (aarch64-apple-darwin20) (161.50 kB)                         
#>  Got lubridate 1.9.0 (aarch64-apple-darwin20) (977.16 kB)                      
#>  Got gtable 0.3.1 (aarch64-apple-darwin20) (159.19 kB)                         
#>  Got lazyeval 0.2.2 (aarch64-apple-darwin20) (159.69 kB)                       
#>  Got rappdirs 0.3.3 (aarch64-apple-darwin20) (46.80 kB)                        
#>  Got pkgbuild 1.3.1 (aarch64-apple-darwin20) (143.57 kB)                       
#>  Got stringr 1.4.1 (aarch64-apple-darwin20) (214.01 kB)                        
#>  Got sys 3.4.1 (aarch64-apple-darwin20) (50.67 kB)                             
#>  Got brio 1.1.3 (aarch64-apple-darwin20) (43.84 kB)                            
#>  Got ggplot2 3.4.0 (aarch64-apple-darwin20) (4.21 MB)                          
#>  Got praise 1.0.0 (aarch64-apple-darwin20) (16.08 kB)                          
#>  Got glue 1.6.2 (aarch64-apple-darwin20) (154.64 kB)                           
#>  Got waldo 0.4.0 (aarch64-apple-darwin20) (99.88 kB)                           
#>  Got rprojroot 2.0.3 (aarch64-apple-darwin20) (100.20 kB)                      
#>  Got bit 4.0.5 (aarch64-apple-darwin20) (1.23 MB)                              
#>  Got tibble 3.1.8 (aarch64-apple-darwin20) (724.32 kB)                         
#>  Got htmltools 0.5.3 (aarch64-apple-darwin20) (341.24 kB)                      
#>  Got withr 2.5.0 (aarch64-apple-darwin20) (229.48 kB)                          
#>  Got dplyr 1.0.10 (aarch64-apple-darwin20) (1.33 MB)                           
#>  Got memoise 2.0.1 (aarch64-apple-darwin20) (47.93 kB)                         
#>  Got nycflights13 1.0.2 (aarch64-apple-darwin20) (4.50 MB)                     
#>  Got stringi 1.7.8 (aarch64-apple-darwin20) (14.52 MB)                         
#> 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 `get_internal(env, name)` at config.R:403:7:                 
#> ! Unknown conifguration entry: `build_vignettes`.                               
#>  This is an probably an internal error in the pkgdepends package.              
#> ---                                                                             
#> Backtrace:                                                                      
#> 1. pak::pkg_install(c("tibble", "DiagrammeR=?ignore", "formattable=…            
#> 2. pak:::remote(function(...) get("pkg_install_do_plan", asNamespace("pak… at pa
#> ckage.R:216:3                                                                   
#> 3. err$throw(res$error) at subprocess.R:92:5                                    
#> ---                                                                             
#> Subprocess backtrace:                                                           
#>  1. base::withCallingHandlers(cli_message = function(msg) { …                   
#>  2. get("pkg_install_do_plan", asNamespace("pak"))(...)                         
#>  3. proposal$get_install_plan() at package.R:255:3                              
#>  4. private$plan$get_install_plan() at pkg-installation.R:493:24                
#>  5. pkgdepends:::pkgplan_install_plan(self, private, downloads = TRUE) at pkg-pl
#> an.R:43:24                                                                      
#>  6. private$config$get("build-vignettes") at solve.R:963:3                      
#>  7. local get_internal(env, name) at config.R:403:7                             
#>  8. base::throw(pkg_error("Unknown conifguration entry: {.code {name}}.", … at c
#> onfig.R:206:7                                                                   
#>  9. | base::signalCondition(cond) at errors.R:252:5                             
#> 10. global (function (e) …                                                      
#> Execution halted                                                                

The syntax is

<packagename>=?ignore

Note that you can only ignore optional dependencies, i.e. packages in Suggests and Enhances.

Others

How can I use pak with renv?

You cannot currently, but keep on eye on this issue: https://github.com/r-lib/pak/issues/343