rv add examples
The rv add command supports a wide range of options for adding packages to your project. This page demonstrates various ways to use rv add with different package sources and configuration options.
Simple Package Addition
Section titled “Simple Package Addition”Add a package using the default behavior - creates a simple string dependency entry:
rv add dplyrResult in rproject.toml:
dependencies = ["dplyr"]Specifying a Repository
Section titled “Specifying a Repository”Add a package from a specific repository using the --repository flag:
rv add polars --repository RMV25Q3Result in rproject.toml:
dependencies = [ { name = "polars", repository = "RMV25Q3" }]This is useful when you need to install a package from a non-default repository, such as R-multiverse snapshots.
Force Source Installation
Section titled “Force Source Installation”Force installation from source for all repositories:
rv add dplyr --force-sourceResult in rproject.toml:
dependencies = [ { name = "dplyr", force_source = true }]Combining Multiple Options
Section titled “Combining Multiple Options”Combine repository targeting, force source, and install suggestions:
rv add dplyr --repository cran --force-source --install-suggestionsResult in rproject.toml:
dependencies = [ { name = "dplyr", repository = "cran", force_source = true, install_suggestions = true }]Git Repository with Tag
Section titled “Git Repository with Tag”Install from a git repository with a specific tag:
rv add my-pkg --git https://github.com/user/repo --tag v1.0.0Result in rproject.toml:
dependencies = [ { name = "my-pkg", git = "https://github.com/user/repo", tag = "v1.0.0" }]Git Repository with All Options
Section titled “Git Repository with All Options”Install from a git repository with branch, subdirectory, and additional options:
rv add my-pkg --git https://github.com/user/repo --branch main --directory subpkg --install-suggestions --dependencies-onlyResult in rproject.toml:
dependencies = [ { name = "my-pkg", git = "https://github.com/user/repo", branch = "main", directory = "subpkg", install_suggestions = true, dependencies_only = true }]Local Path
Section titled “Local Path”Install a package from a local path:
rv add my-pkg --path ../my-packageResult in rproject.toml:
dependencies = [ { name = "my-pkg", path = "../my-package" }]Package Archive URL
Section titled “Package Archive URL”Install from a direct URL to a package archive:
rv add dplyr --url https://cran.r-project.org/src/contrib/Archive/dplyr/dplyr_1.1.3.tar.gzResult in rproject.toml:
dependencies = [ { name = "dplyr", url = "https://cran.r-project.org/src/contrib/Archive/dplyr/dplyr_1.1.3.tar.gz" }]Dependencies-Only Mode
Section titled “Dependencies-Only Mode”Install only the dependencies of a package without installing the package itself. This is particularly useful when actively developing a package:
rv add my-dev-pkg --path . --dependencies-onlyResult in rproject.toml:
dependencies = [ { name = "my-dev-pkg", path = ".", dependencies_only = true }]This installs all dependencies of my-dev-pkg but not my-dev-pkg itself, which is ideal for development workflows.