Skip to content

Installing Packages

In other R tools, individual packages are installed and removed through separate commands (i.e. install.packages() and remove.packages()) In rv, a project is synchronized across the config file, lock file, and the project library, performing whatever actions, including installation and removal of packages and dependencies, is necessary to reach the synchronized state. Therefore, package(s) installation is called sync in rv.

Every time a package is changed - added, removed, new version, source changed - the lockfile is automatically updated to reflect the new state of the project library.

Terminal window
rv sync [OPTIONS]
rproject.toml
[project]
name = "my project"
r_version = "4.4"
repositories = [
{ alias = "PPM", url = "https://packagemanager.posit.co/cran/latest" }
]
dependencies = [
"tibble",
]

For quick editing and installation, rv add pkg1 pkg2... can be used to add these packages as dependencies to the config file and then sync. Currently, rv only adds packages as simple dependencies. To add packages with additional options, the config file is intended to be edited and then run rv sync.

Using this command may feel similar to install.packages() where packages can be iteratively added to the project, just with the additional benefit of rv.

Terminal window
rv add [OPTIONS] [packages]...
  • packages - A list of packages, space separated, to add to the project
  • --dry-run - No changes made to the config or the package library, only reports what would happen if the command was run.
  • --no-sync - Packages are added to the config file, but not sync’ed.
rproject.toml
[project]
name = "my project"
r_version = "4.4"
repositories = [
{ alias = "PPM", url = "https://packagemanager.posit.co/cran/latest" }
]
dependencies = [
"tibble",
]

rv will default to installing packages from the source they are locked in, as long as that source is still within the configuration file, as discussed in the Resolution Reference.

rv upgrade will ignore the lockfile, re-resolve, and install any changed packages. This does not necessarily upgrade to the latest version available across repositories, nor guarantee the packages will be sourced from a the same repository. Rather, your project state will be set as if there was no lockfile present.

Terminal window
rv upgrade [OPTIONS]
  • --dry-run - No changes made, only reports what would happen if the command was run.