Installing a Specific Package Version
As mentioned in the repository dependency configuration note,
rv intentionally 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 a direct url configuration.
On this page, we will consider the scenario where we would like to install jsonlite 1.9.1 but jsonlite 2.0.0 is the version available in the repository
used by other packages.
Through an Older Snapshot
Section titled “Through an Older Snapshot”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.
[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 = [ { name = "jsonlite", repository = "PPM_old" }, # Will install from PPM_old]Installation Results
Section titled “Installation Results”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.
% rv sync...+ jsonlite (1.9.1, binary from https://packagemanager.posit.co/cran/2025-03-13) in 632msAdditionally, 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.
Through an Archive/Tarball
Section titled “Through an Archive/Tarball”If adding a different snapshot is not desired, we can add the dependency using the url configuration to point to the Archive.
In a CRAN-like repository, packages are found in the archive in the pattern {repo url}/src/contrib/Archive/{pkg name}/{pkg name}_{pkg version}.tar.gz
[project]name = "archive"r_version = "4.4"
repositories = [ # This repository can be any CRAN mirror. For this example, setting a stable snapshot for reproducible versions. { alias = "PPM", url = "https://packagemanager.posit.co/cran/2025-05-01" },]
dependencies = [ # "jsonlite", # would install `jsonlite 2.0.0` { name = "jsonlite", url = "https://cran.r-project.org/src/contrib/Archive/jsonlite/jsonlite_1.9.1.tar.gz" },]Installation Results
Section titled “Installation Results”Below is the result of syncing the project. Notice, all other packages (including potential dependencies of the archived package) are sourced from the specified repository.
% rv sync...+ jsonlite (1.9.1, source from https://cran.r-project.org/src/contrib/Archive/jsonlite/jsonlite_1.9.1.tar.gz) in 2549ms