Overriding Remote Dependencies
Sometimes packages, especially internal or still in development, have dependencies which are not widely available.
In this case, the package may contain the Remotes
field to describe where the installer can find these dependencies.
This is great for a lot of scenarios, for example, if you want to install the package, the installer just “knows” how to install a package.
But there are scenarios where a package is contained in a repository and the installer, including rv
, still prefers the remote dependency
As discussed in prefer_repositories_for
, rv
has the power to prefer repositories
over remotes for explicit dependencies following the conditions mentioned.
In this example, we will try to install the simple example package rv.remotes
,
which depends on tibble >= 3.2.0
and glue >= 1.7.0
, but has remotes specified for those packages as well. First, we’ll look at how the installation
would occur without additional configuration. Then, we’ll add the prefer_repositories_for
field to the config file and see how it changes.
Without Additional Configuration
Section titled “Without Additional Configuration”In the initial configuration, we start with a repository which contains tibble 3.2.1
and glue 1.8.0
and try to install the rv.remotes
package
from the main git branch.
[project]name = "remotes"r_version = "4.4"
repositories = [ { alias = "PPM", url = "https://packagemanager.posit.co/cran/2025-05-01" },]
dependencies = [ { name = "rv.remotes", git = "https://github.com/a2-ai/rv.remotes", branch = "main" }]
We can see in the summary
and plan
that we will install tibble
and glue
from the specified git remote, and not from the repositories.
== System Information ==OS: macos (arm64)R Version: 4.4
Num Workers for Sync: 8 (8 cpus available)Cache Location: /Users/wescummings/projects/rv-docs-playground/cache/rv
== Dependencies ==Library: rv/library/4.4/arm64Installed: 0/11
Package Sources:https://github.com/a2-ai/rv.remotes: 0/1 source packageshttps://github.com/tidyverse/glue: 0/1 source packageshttps://github.com/tidyverse/tibble: 0/1 source packagesPPM: 0/8 binary packages
Installation Summary:https://github.com/a2-ai/rv.remotes: 1/1 in cache (1 to compile)https://github.com/tidyverse/glue: 1/1 in cache (1 to compile)https://github.com/tidyverse/tibble: 1/1 in cache (1 to compile)PPM: 8/8 to download
== Remote ==PPM (https://packagemanager.posit.co/cran/latest): 19436 binary packages, 22462 source packages
+ cli (3.6.5, binary from https://packagemanager.posit.co/cran/latest)+ glue (1.8.0, source from https://github.com/tidyverse/glue (commit: 48688f8f720a8f043b0f989b518a42bc32c410f0))+ lifecycle (1.0.4, binary from https://packagemanager.posit.co/cran/latest)+ magrittr (2.0.3, binary from https://packagemanager.posit.co/cran/latest)+ pillar (1.10.2, binary from https://packagemanager.posit.co/cran/latest)+ pkgconfig (2.0.3, binary from https://packagemanager.posit.co/cran/latest)+ rlang (1.1.6, binary from https://packagemanager.posit.co/cran/latest)+ rv.remotes (0.0.1, source from https://github.com/a2-ai/rv.remotes (branch: main))+ tibble (3.2.1.9054, source from https://github.com/tidyverse/tibble (commit: 880e9f3aa64d4d02f4fe427016d554a5d1a10c73))+ utf8 (1.2.5, binary from https://packagemanager.posit.co/cran/latest)+ vctrs (0.6.5, binary from https://packagemanager.posit.co/cran/latest)
With Configuration
Section titled “With Configuration”Since we have packages in the repository that meet the version requirements in rv.remotes
DESCRIPTION file, we can prefer the repository for those packages.
We do this by first adding it to the config file:
[project]name = "remotes"r_version = "4.4"
repositories = [ { alias = "PPM", url = "https://packagemanager.posit.co/cran/2025-05-01" },]
dependencies = [ { name = "rv.remotes", git = "https://github.com/a2-ai/rv.remotes", branch = "main" }]
prefer_repositories_for = [ "glue", "tibble",]
We can now see that tibble
and glue
are not sourced from GitHub anymore and are sourced from the repository as specified.
== System Information ==OS: macos (arm64)R Version: 4.4
Num Workers for Sync: 8 (8 cpus available)Cache Location: /Users/wescummings/projects/rv-docs-playground/cache/rv
== Dependencies ==Library: rv/library/4.4/arm64Installed: 0/12
Package Sources:PPM: 0/11 binary packageshttps://github.com/a2-ai/rv.remotes: 0/1 source packages
Installation Summary:PPM: 11/11 to downloadhttps://github.com/a2-ai/rv.remotes: 1/1 in cache (1 to compile)
== Remote ==PPM (https://packagemanager.posit.co/cran/latest): 19436 binary packages, 22462 source packages
+ cli (3.6.5, binary from https://packagemanager.posit.co/cran/latest)+ fansi (1.0.6, binary from https://packagemanager.posit.co/cran/latest)+ glue (1.8.0, binary from https://packagemanager.posit.co/cran/latest)+ lifecycle (1.0.4, binary from https://packagemanager.posit.co/cran/latest)+ magrittr (2.0.3, binary from https://packagemanager.posit.co/cran/latest)+ pillar (1.10.2, binary from https://packagemanager.posit.co/cran/latest)+ pkgconfig (2.0.3, binary from https://packagemanager.posit.co/cran/latest)+ rlang (1.1.6, binary from https://packagemanager.posit.co/cran/latest)+ rv.remotes (0.0.1, source from https://github.com/a2-ai/rv.remotes (branch: main))+ tibble (3.2.1, binary from https://packagemanager.posit.co/cran/latest)+ utf8 (1.2.5, binary from https://packagemanager.posit.co/cran/latest)+ vctrs (0.6.5, binary from https://packagemanager.posit.co/cran/latest)