PecanProject / pecan

The Predictive Ecosystem Analyzer (PEcAn) is an integrated ecological bioinformatics toolbox.
www.pecanproject.org
Other
199 stars 231 forks source link

Install versioned dependencies from a fresher CRAN mirror instead of from Github #3244

Closed infotroph closed 5 months ago

infotroph commented 6 months ago

Description

Changes dependency installation to use two different CRAN sources: Most packages continue to come from a fixed-date snapshot the same age as the R version (same as before this PR), but now will consult a newer CRAN mirror for packages that both:

Motivation and Context

Our Docker images inherit the CRAN settings of the Rocker images we build them from, which all use static snapshots that match the age of the version of R they are built for. This is usually what we want -- someone running an old version of R is likely also running old versions of at least some packages, so it makes sense to test PEcAn on a range of dependency versions as well as R versions.

But there are cases where we really do need a functionality or bugfix that is only available in a version of a dependency that was released later than the oldest CRAN snapshot we want to test against. Until now, we've handled this by installing these dependencies from GitHub, usually pinning them to the oldest version known to work. This increases build time (install_github is always from source whereas the Posit package manager gives us prebuilt binaries), creates confusion when the version we pinned goes out of date ("why are we installing this old version of rmarkdown from GitHub instead of using the one on CRAN?"), and generally feels silly.

The change I make here is to take advantage of a nice difference in behavior of remotes::install_version compared to base::install.packages: If argument repos has length > 1, install.packages checks all repositories and installs the newest available version of a package, while install_version checks them in order and installs the first one that matches your version requirements. By looking first in the fixed snapshot and then in the current version of CRAN, we can get several nice properties:

Review Time Estimate

Types of changes

Checklist: