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.
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.
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.)
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).