FAQ {pak}R Documentation

Frequently Asked Questions

Description

Please take a look at this list 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.68 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.68 MB) are cached                 
#>  Got utf8 1.2.2 (aarch64-apple-darwin20) (209.24 kB)                   
#>  Installed cli 3.3.0  (76ms)                                           
#>  Installed crayon 1.5.1  (87ms)                                        
#>  Installed ellipsis 0.3.2  (97ms)                                      
#>  Installed fansi 1.0.3  (103ms)                                        
#>  Installed glue 1.6.2  (111ms)                                         
#>  Installed lifecycle 1.0.1  (153ms)                                    
#>  Installed magrittr 2.0.3  (158ms)                                     
#>  Installed pillar 1.7.0  (162ms)                                       
#>  Installed pkgconfig 2.0.3  (87ms)                                     
#>  Installed rlang 1.0.2  (39ms)                                         
#>  Installed tibble 3.1.7  (41ms)                                        
#>  Installed utf8 1.2.2  (39ms)                                          
#>  Installed vctrs 0.4.1  (32ms)                                         
#>  1 pkg + 12 deps: added 13, dld 1 (209.24 kB) [1.8s]                   
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  (42ms)                                        
#>  1 pkg + 12 deps: kept 11, added 1 [343ms]                             

How do I install a dependency from a binary package

Sometimes it is sufficient to install the binary package of an older version of a dependency, instead of the newer source package that potentially needs compilers, system tools or libraries.

pkg_install() and lockfile_create() default to upgrade = FALSE, which always chooses binaries over source packages, so if you use pkg_install() you don't need to do anything extra.

The ⁠local_install_*⁠ functions default to upgrade = TRUE, as does pak() with pkg = NULL, so for these you need to explicitly use upgrade = FALSE.

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                  
#>  Building tibble 3.1.7                                                 
#>  Built tibble 3.1.7 (3.1s)                                             
#>  Installed tibble 3.1.7  (35ms)                                        
#>  1 pkg + 12 deps: kept 11, added 1 [4.1s]                              

How do I install the latest version of a dependency?

If you want to always install a dependency from source, because you want the latest version or some other reason, you can use the source parameter with the ⁠<package>=⁠ form: ⁠<package>=?source⁠. For example to install tibble, with its cli dependency installed from source you could write:

pak::pkg_install(c("tibble", "cli=?source"))
#>                                                                         
#> → Will install 1 package.                                               
#> → The package (540.04 kB) is cached.                                    
#> + cli   3.3.0 👷🏽🔧                                                       
#>  No downloads are needed, 1 pkg (540.04 kB) is cached                  
#>  Building cli 3.3.0                                                    
#>  Built cli 3.3.0 (4.5s)                                                
#>  Installed cli 3.3.0  (68ms)                                           
#>  1 pkg + 12 deps: kept 11, added 1 [4.9s]                              

How do I ignore an optional dependency?

pak::pkg_install(
  c("tibble", "DiagrammeR=?ignore", "formattable=?ignore"),
  dependencies = TRUE
)
#>                                                                         
#>  No downloads are needed                                               
#>  1 pkg + 12 deps: kept 12 [583ms]                                      

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


[Package pak version 0.7.2 Index]