Skip to contents

Emits or installs the R code lines that point options(repos) at a Posit Package Manager binary repository. With dry_run = TRUE (the default), the lines are returned without touching any file, so the user can review them before applying. When dry_run = FALSE, path must always be supplied explicitly; no file is ever chosen automatically.

Usage

use_ppm(
  scope = c("user", "project"),
  platform = NULL,
  repo = "cran",
  dry_run = TRUE,
  path = NULL
)

Arguments

scope

Intended .Rprofile location, "user" or "project". The function never picks a file itself; scope only shapes the path suggestion shown when dry_run = FALSE is called without path (the user .Rprofile for "user", the project .Rprofile for "project").

platform

Platform specification accepted by resolve_platform().

repo

Repository name.

dry_run

If TRUE, return the lines that would be written without editing files.

path

Explicit .Rprofile path. Required when dry_run = FALSE.

Value

The configuration lines, invisibly when written.

Examples

use_ppm("user", platform = "ubuntu-22.04", dry_run = TRUE)
#> [1] "options("                                                                  
#> [2] "  repos = c("                                                              
#> [3] "    CRAN = \"https://packagemanager.posit.co/cran/__linux__/jammy/latest\""
#> [4] "  )"                                                                       
#> [5] ")"                                                                         

# Write to a throwaway .Rprofile under tempdir():
use_ppm(
  "user",
  platform = "ubuntu-22.04",
  dry_run = FALSE,
  path = file.path(tempdir(), ".Rprofile")
)