Skip to content

Configuring R Environments#

Once you have obtained the repository URL, your environment must be configured to use the URL to download and install packages.

Base R#

To configure R to use Package Manager as its CRAN repository, set the repos option to use the repository URL:

options(repos = c(CRAN = ""))

Alternatively, instead of replacing your default URL, additional repositories can be added to your existing configuration. For example:

  repos <- c(PackageManager = "")
  repos["LocalPackages"] <- ""

  # add the new repositories first, but keep the existing ones
  options(repos = c(repos, getOption("repos")))

# verify the current repository list
<<                                                   PackageManager
<<  ""
<<                                                    LocalPackages
<< ""
<<                                                             CRAN
<<                                    ""

The same code can be added to your R startup file ( or .Rprofile) to maintain the repository configuration across R sessions. See our article on managing R startup files for more information.


If you are installing packages on Linux and want to take advantage of pre-built binary packages for speed and reliability, follow the instructions in Configuring the R User Agent Header to set up or verify your configuration.

RStudio Desktop or Posit Workbench#

In RStudio Desktop or Posit Workbench, repository settings are configured through the Global Options menu available from the Tools section of the main toolbar.

RStudio Desktop Tools > Global Options screenshot

From the left pane, click Packages , paste the repository URL into the Primary CRAN repository field or click Add to include this repository as a secondary repository.

RStudio Desktop Global Options screenshot for setting CRAN repository

Your Posit Workbench administrator can also configure the default repository for all users to point to Package Manager. See Configuring Posit Workbench for more information.