Can one perform a dry run of a package installation?

Hi,

Is there a way to do a dry run of install.packages() or update.packages() to simulate how an R environment would be modified by the installation or update of a particular set of packages (with their dependencies)?

I am particularly interested in finding how dependencies would be recursively updated to newer versions.

Thanks

2 Likes

What about creating a temporary library? So something like

tmp_lib = tempdir()
install.package("XXX", lib = tmp_lib)
library("XXX", lib.loc = tmp_lib)

Using tempdir() should be cross platform, will be unique and will (probably) get deleted at some point.

1 Like

The latest version of devtools::install_github() does something like this, because I know it has prompted me for the version changes, so I can select which I wanted to update.

The new package pak does this.

library(pak)
pak::pkg_install("ggplot2")

Since ggplot2 was already installed on my machine, this does nothing:

i Checking for package metadata updates
v Downloaded metadata files, 2.35 MB in 4 files.                                                     
√ Updating metadata database                                                                       
v Using cached package metadata                                                                      
v 1 + 32 pkgs | kept 29, updated 0, new 0 | downloaded 0 (0 B) [11.8s] 

But using update = TRUE triggers a dry run of what will happen:

pak::pkg_install("ggplot2", upgrade = TRUE)

Resulting in:

i Checking for package metadata updates
v All 10 metadata files are current.                                                                 
v Using session cached package metadata                                                              
v Using cached package metadata                                                                      
                                                                                                     
> Will update 4 packages:
  Matrix, mgcv, MASS, nlme
  
> Will not update 29 packages.

> Will download 3 CRAN packages (7.88 MB).
> Will download 1 packages with unknown size.

? Do you want to continue (Y/n) 

The package pak is on CRAN, has pkgdown documentation at https://pak.r-lib.org/ and a recording of Gabor's video at RStudio::conf(2019). (Note that in the video, the package was still called pkgman, and was subsequently renamed to pak.)

2 Likes

Thanks all for you responses,

Ideally, I would like to avoid the actual installation... but, for now, I think I will go with Collin's suggestion because pak has way too many dependencies for what I would use it for (and I am not even sure it would avoid the actual installation).

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.