Configuring RStudio Server

Administrators can configure RStudio Server (Pro) to automatically use RStudio Package Manager when users install packages.

The necessary configuration files are documented in the RStudio Server admin guide, example configurations are provided here for common scenarios.

A Single Repository

In the most common scenario, users will install all packages from a single RStudio Package Manager repository that may contain CRAN packages and internal packages. An admin can discourage users from changing this repository setting. In this scenario, configure RStudio Server:

  1. In /etc/rstudio/rsession.conf, set:

    bash r-cran-repos=https://<your-package-manager-server-address>/<repo-name>/latest

    The exact URL to use is available in the RStudio Package Manager Setup page for the repository.

  2. (RStudio Server Pro only) To disable the repository option menu and discourage users from changing the repository setting, also include in /etc/rstudio/rsession.conf:

    allow-r-cran-repos-edit=0
    

Internal Packages and CRAN Packages

Another common scenario is to setup two repositories in RStudio Package Manager, one to serve CRAN packages and one to serve internal packages. (This setup also applies if you're only using RStudio Package Manager for internal packages and want to allow users to access a public CRAN mirror).

  1. In /etc/rstudio/rsession.conf, remove any existing r-cran-repos configuration.
  2. Create a file called /etc/rstudio/repos.conf. The file should contain:
CRAN=https://<your-package-manager-server-address>/<cran-repo-name>/latest
Internal=https://<your-package-manager-server-address>/<internal-repo-name>/latest

The name Internal can be replaced with whatever name makes sense for your organization, but the repo containing CRAN packages should be indexed with the keyword CRAN.

Allow Users to Optionally Add Additional Repos

In addition to the two scenarios described above, some organizations may have additional repositories for certain groups of users, e.g. "bleeding edge" packages available in a dedicated "dev" repository. Administrators can configure RStudio's Global Options menu to automatically offer RStudio Package Manager repositories as optional, secondary repos that a user can opt into using.

In /etc/rstudio/rsession.conf, set:

r-cran-repos-url=https://<your-package-manager-server-address>/__api__/repos
allow-r-cran-repos-edit=1

Binary Packages

RStudio Package Manager supports serving precompiled binary packages for the CRAN source, which can significantly speed up CRAN package installations.

To enable binary packages for users, follow the Configuration Steps and the R Configuration Steps for Linux or Windows to set up your R environment. For Linux binaries, also configure RStudio Server to use the binary repository URLs.

Precedence of Settings

If you have an Rprofile.site file that modifies the repository setting, that file will take precedence over these settings.

Some Ubuntu and Debian R binaries (installed via apt-get install) include an Rprofile.site file that modifies the repository option. Unless you intended to have this file, we recommend removing /usr/lib/R/etc/Rprofile.site.

Checking For Success

Once edits have been made to the appropriate configuration files (see above), start a new RStudio Server session. Closing and reopening the browser tab or pressing the reload button on the browser does not start a new session.

At that point, running options('repos') from the RStudio Server console should return the URL of the RSPM instance you've configured.

An alternative test is to download a package to RStudio Server and check where it came from by running:

install.packages("test-package")
packageDescription("test-package")

The Repository line in the output should read RSPM.

While you obviously can install any package as a test, one that is small and has no or lightweight dependencies will be the quickest. The A3 package on CRAN is the first alphabetically that meets this criteria.