Skip to content

Installing an Older Package Version from a Snapshot

As mentioned in the repository dependency configuration note, rv intentially does not have a way to specify a version directly. Instead, you can add an older snapshot and specify an out of order repository or install a package using the url configuration to install a package from the archive, as seen in the archive package example.

In this example we would like to install jsonlite 1.9.1 and cli, but jsonlite 2.0.0 is the version available in the repository.

We must first determine a snapshot that contains the version of interest. Looking at jsonlite in Posit Package Manager, we see that 2.0.0 is release on 27-Mar-2025 and 1.9.1 is released on 03-Mar-2025, therefore any snapshot date between those two dates will contain 1.9.1.

We will add this repository snapshot AFTER the more up-to-date repository.

Then we add the dependency, specifying it to come from the new snapshot using the alias.

rproject.toml
[project]
name = "archive"
r_version = "4.4"
repositories = [
{ alias = "PPM", url = "https://packagemanager.posit.co/cran/2025-05-01" },
{ alias = "PPM_old", url = "https://packagemanager.posit.co/cran/2025-03-13" },
]
dependencies = [
"cli", # Will install from PPM
# "jsonlite", # would install `jsonlite 2.0.0`
{ name = "jsonlite", repository = "PPM_old" }, # Will install from PPM_old
]

Below is the result of syncing the project.By utilizing a snapshot repository, we are able to still get a binary, which is much faster than source compilation of an archive version as seen in the archive example.

Terminal window
$ rv sync
+ cli (3.6.5, binary from https://packagemanager.posit.co/cran/2025-05-01) in 595ms
+ jsonlite (1.9.1, binary from https://packagemanager.posit.co/cran/2025-03-13) in 632ms

Additionally, by adding the older snapshot date, if dependency constraints from the older package version cannot be met in the newer repository, dependencies can come from the older repository.