Skip to content

rv add

Used to quickly add packages to the config file and syncing.

The rv add command supports adding packages as simple dependencies or with advanced configuration options like specifying repositories, git sources, local paths, URLs, and various installation behaviors.

Using this command may feel similar to install.packages() in which packages can be iteratively added to the project, just with the additional benefits provided by rv.

Terminal window
rv add [packages]... [OPTIONS]
  • packages - A list of packages to add to the project, given as separate arguments (e.g. rv add dplyr tidyr)
  • --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 synced.
  • --repository <ALIAS> - Specify which repository to install from (e.g., cran, bioc). Creates a table entry with the repository field.
  • --git <URL> - Install from a git repository. Creates a table entry with the git field.
    • --tag <TAG> - Specify a git tag (requires --git, conflicts with --commit/--branch)
    • --branch <BRANCH> - Specify a git branch (requires --git, conflicts with --commit/--tag)
    • --commit <SHA> - Specify a git commit SHA (requires --git, conflicts with --tag/--branch)
    • --directory <DIR> - Specify subdirectory within git repo (requires --git)
  • --path <PATH> - Install from a local path. Creates a table entry with the path field.
  • --url <URL> - Install from a URL to a package archive. Creates a table entry with the url field.
Introduced in rv v0.22.0

As a shortcut for --git, a package argument in the form owner/repo is treated as a git source, resolved against https://github.com (or git_shorthand_base_url if configured):

  • rv add r-lib/cli - installs from the repository’s default branch
  • rv add r-lib/cli@v3.6.2 - installs from a tag, branch, or commit SHA (auto-detected)
  • rv add r-lib/cli@branch:main, @tag:v3.6.2, or @commit:9a8c5d2 - explicitly typed reference
  • rv add r-lib/usethis@tag:v2.2.3:r-package - reference plus a subdirectory within the repo
  • --force-source - Forces the package to be fetched and installed as source from a repository. Adds force_source = true to the dependency entry.
  • --install-suggestions - Install suggested packages. Adds install_suggestions = true to the dependency entry.
  • --dependencies-only - Install only the dependencies of the package, not the package itself. Adds dependencies_only = true to the dependency entry. Useful when developing a package locally.

A number of examples demonstrating the various options and capabilities of rv add are shown in the Cookbook section.