# 5 R Sessions

## 5.1 R Executable and Libraries

### 5.1.1 Locating R

RStudio Server uses the version of R pointed to by the output of the following command:

#### 5.2.4.2 Scheduling Priority

The nice setting specifies a relative priority for scheduling session CPU time. Negative 20 is the highest nice priority and positive 20 is the lowest priority. The system default niceness for processes is typically 0. The following are all valid nice values:

nice = -10
nice = 0
nice = 15

Scheduler behavior around nice priorities varies by system. For more details see nice use and effect.

### 5.2.5 Resource Limits

Profiles can also be used to specify limits on available memory as well as the maximum number of processes and open files.

#### 5.2.5.1 Available Memory

The max-memory-mb setting controls the maximum amount of addressable memory for R sessions (by default memory is unlimited). This example specifies a limit of 2GB:

max-memory-mb = 2048

Note that this value sets the amount of virtual memory that can be used by a process. Virtual memory includes code (i.e. shared libraries) loaded by the process as well as things like memory mapped files, so can often consume several hundred megabytes even for a vanilla R session. Therefore, you want to be sure not to set this threshold too low (in no case should you set it below 1024).

#### 5.2.5.2 Number of Processes

The max-processes settings controls the maximum number of processes createable by a user. This setting is useful to prevent either inadvertent or malicious fork bombs. The following example sets a limit of 200 processes:

max-processes = 200

Note that users need to be able to create a minimum number of processes in order to use RStudio Server so we don’t recommend setting this value below 25.

#### 5.2.5.3 Number of Open Files

In most Linux environments there is a maximum of 1024 open files per process. This is typically more than enough, but if you have a particular applications that requires more open files the max-open-files setting can be used to increase the limit. For example:

max-open-files = 2048

### 5.2.6 Using Multiple Versions of R

As illustrated above, you can bind users or groups to distinct versions of R installed on your server. This is controlled by the r-version option. Here are several examples of it’s use:

r-version = /usr/lib/R
r-version = /usr/local/lib/R
r-version = /opt/R/3.1.0
r-version = /opt/R/3.2.0

Note that r-version specifies the full path to the directory where R is installed.

See the R Versions chapter for additional details on running multiple versions of R on a single server.

## 5.3 Multiple R Sessions

RStudio Server Professional enables users to have multiple concurrent R sessions on a single server or load balanced cluster of servers (the open-source version of RStudio Server supports only a single session at a time).

### 5.3.1 Creating New Sessions

You can start a new R Session using the New Session command from the Session menu (or the corresponding toolbar button near the top-right of the IDE).

You can also open an existing RStudio project in a new R session by using the Open Project in New Session command. When switching projects there is also a button on the right side of the projects menu that lets you specify that the project should be opened in a new session rather than within the current one.

You can review all currently running sessions and switch between them using the Sessions toolbar near the top-right of the IDE.

R Sessions are long-running tasks that continue to be available until you explicitly quit them (you can think of them as you’d think of multiple top-level RStudio windows running on the desktop). This means that you can kickoff a long running job in one session and then switch to another session, revisiting the original session later to check on it’s progress. As is also possible on the desktop, you can navigate between different projects and working directories within a session.

Sessions will suspend automatically when they are idle and then be automatically resumed next time they are accessed. To permanently quit a session you can use the Quit Session command located on the File menu or the corresponding toolbar button at the top right of the IDE.

### 5.3.3 Disabling Multiple Sessions

If you wish disable support for multiple sessions you can use the server-multiple-sessions option. For example:

/etc/rstudio/rserver.conf

server-multiple-sessions=0

## 5.4 PAM Sessions

RStudio Server Professional uses PAM (Pluggable Authentication Modules) for both user authentication as well to establish the environment and resources available for R sessions. This is accomplished using the PAM session API. PAM sessions are used for a variety of purposes:

1. To initialize environment variables
2. To automatically create local users after authentication against a directory server.
3. To mount remote drives
4. To initialize and destroy Kerberos tickets

This section explains how to configure and customize PAM sessions with RStudio Server.

### 5.4.1 Session PAM Profile

For PAM authentication RStudio Server uses the either the /etc/pam.d/other profile (Debian/Ubuntu) or /etc/pam.d/rstudio profile (RedHat/CentOS). However, for launching R sessions a different PAM profile is used. This is because the launching of R sessions may not coincide with authentication (e.g. returning to the site with login credentials cached in a cookie or resuming a suspended session). Therefore, the PAM directive that enables authentication with root privilege only (auth sufficient pam_rootok.so) needs to be present in the PAM profile.

The behavior that RStudio Server requires is essentially same as that of the su command (impersonation of a user without a password). Therefore by default RStudio Server uses the /etc/pam.d/su profile for running R sessions.

#### 5.4.1.1 Creating a Custom Profile

The /etc/pam.d/su profile has different default behavior depending upon your version of Linux and local configuration. Depending upon what type of behavior you want associated with R sessions (e.g. mounting of disks, setting of environment variables, enforcing of resource limits, etc.) you’ll likely want to create a custom profile for R sessions. For example, if you wanted to use a profile named rstudio-session you would add this to the configuration file:

/etc/rstudio/rserver.conf

auth-pam-sessions-profile=rstudio-session

Here is in turn what the custom profile might contain in order to enable a few common features of PAM sessions (this is based on a modified version of the default su profile on Ubuntu):

/etc/pam.d/rstudio-session

# This allows root to su without passwords (this is required)
auth       sufficient pam_rootok.so

# This module parses environment configuration file(s)
# and also allows you to use an extended config
# file /etc/security/pam_env.conf.

# Locale variables are also kept into /etc/default/locale in etch

# Enforces user limits defined in /etc/security/limits.conf
session    required   pam_limits.so

# The standard Unix authentication modules
@include common-auth
@include common-account
@include common-session

#### 5.4.1.2 Custom Profile with Passwords

Note that in the above configuration we rely on pam_rootok.so to enable authentication without a password. This is necessary because RStudio Server doesn’t retain the passwords used during the authentication phase.

In some situations however passwords are important for more than just authentication. PAM profiles support a use_first_pass directive to forward passwords used during authentication into other modules (for example, to request a Kerberos ticket with pam_krb5.so or to mount an encrypted or remote drive with pam_mount.so). For these scenarios RStudio Server supports an optional mode to retain passwords after login and then forward them into the PAM session profile. This is enabled via the auth-pam-sessions-use-password setting:

/etc/rstudio/rserver.conf

auth-pam-sessions-use-password=1

In this scenario you should remove the auth sufficient pam_rootok.so directive and replace it with whatever authentication directives apply in your environment. You can then employ the use_first_pass directive to forward the password as necessary to other modules.

For example, here’s a very simple RedHat/CentOS PAM configuration file that uses system default authentication and forwards the password into the pam_mount.so module. Note that we are no longer using pam_rootok.so because the password is now available when the session is created.

/etc/pam.d/rstudio-session

# Auth/account (use system auth and forward password to pam_mount)
auth     include    system-auth
auth     optional   pam_mount.so use_first_pass
account  required   pam_unix.so

# Session (read environment variables and enforce limits)
session  required   pam_limits.so

Note that this configuration requires that RStudio Server retain user passwords in memory. This retention is done using industry best-practices for securing sensitive in-memory data including disabling ptrace and core dumps, using mlock to prevent paging into the swap area, and overwriting the contents of memory prior to freeing it.

### 5.4.2 PAM Session Cleanup

By default, RStudio Server does not close PAM sessions when their associated R process exits. This is because PAM sessions often initialize and maintain resources that require more persistence that the lifetime of a single R session (e.g. mounted drives, Kerberos tickets, etc.). If a user has multiple active R sessions then closing the PAM session associated with one of them might unmount a drive or revoke a ticket that is still required by another R session.

It is however possible to manually close the PAM session associated with an R session by force suspending it. This can be accomplished in one of two ways:

1. By pressing the Suspend button on the Sessions page of the Administrative Dashboard.

2. By executing a force-suspend or force-suspend-all command as described in Suspending Sessions.

If you prefer that PAM sessions be closed whenever their associated R session exits you can use the auth-pam-sessions-close setting. For example:

/etc/rstudio/rserver.conf

auth-pam-sessions-close=1

Note that if you specify this setting be aware that depending upon what resources are managed by your PAM sessions it may be incompatible with users running multiple concurrent R sessions (because for example a drive might be unmounted from underneath a running session). In this case you may wish to disable support for multiple R sessions (see the section on Multiple R Sessions for details on how to do this).

### 5.4.3 Disabling PAM Sessions

If you don’t want RStudio Server to utilize PAM sessions you can disable this feature using the auth-pam-sessions-enabled setting. For example:

/etc/rstudio/rserver.conf

auth-pam-sessions-enabled=0

## 5.5 Kerberos

You can use PAM sessions to arrange for Kerberos tickets to be made available for use by R sessions. This is accomplished using the pam_krb5 PAM module. Note that you may need to install this module separately depending on which Linux distribution/version you are running.

### 5.5.1 Configuration

NOTE: You should be sure to understand the previous section on PAM Sessions before attempting to modify your configuration to support Kerberos.

The following are simple examples of the pam_krb5 configuration directives you would need to add to your RStudio PAM configuration files. Note that pam_krb5 supports a large number of options, some of which may be required to get Kerberos working correctly in your environment. You should consult the pam_krb5 documentation before proceeding to ensure you’ve specified all options correctly.

The main PAM profile for RStudio should be modified to include the following pam_krb5 directives:

/etc/pam.d/rstudio

auth       sufficient     pam_krb5.so debug
account    required       pam_krb5.so debug
session    requisite      pam_krb5.so debug

In addition to modifying the main PAM profile, you will also need to create a custom PAM session profile for RStudio (as described in Creating a Custom Profile). This needs to include the appropriate pam_krb5 directives based on your local Kerberos configuration. For example:

/etc/pam.d/rstudio-session

auth        required      pam_krb5.so debug
account     [default=bad success=ok user_unknown=ignore] pam_krb5.so debug
session     requisite     pam_krb5.so debug

Note that typically when you create a custom PAM session profile you include the auth sufficient pam_rootok.so directive. However, in the case of configuring for Kerberos authentication you do not want this directive, rather you need to specify that authentication is done by Kerberos using an explicit password as illustrated in the above example.

To ensure that the custom PAM session profile is used by RStudio Server and that PAM passwords are correctly forwarded to pam_krb5 you’ll also need to add the following entries to the rserver.conf config file:

/etc/rstudio/rserver.conf

auth-pam-sessions-profile=rstudio-session
auth-pam-sessions-use-password=1

• The debug action in the PAM profiles is not required however we recommend adding it as it makes troubleshooting much more straightforward.

• The examples above are not complete examples of the contents of the PAM profiles but rather illustrations of the pam_krb5 entries that need to be present. Your local environment may have many additional entries which you should ensure are also included as necessary.

You should be sure to suspend active R sessions and to restart RStudio Server after making configuration changes to ensure that the new settings are being used. You can do this as follows:

sudo rstudio-server force-suspend-all
sudo rstudio-server restart

### 5.5.2 Testing and Troubleshooting

After making the required configuration changes you should test your updated PAM configuration in isolation from RStudio Server using the pamtester utility as described in Diagnosing PAM Authentication Problems. The following command will test both authentication as well as issuing of Kerberos tickets:

sudo /usr/lib/rstudio-server/bin/pamtester --verbose \
rstudio-session <user> authenticate setcred open_session

Note that you should substitute an actual local username for the <user> part of the command line.

The specifics of both PAM configuration and Kerberos configuration can vary substantially by environment. As a result correct configuration likely requires additional entries and options which this guide isn’t able to cover. Please refer to the documentation linked to in [PAM Resources] as well as the pam_krb5 for additional details.

## 5.6 Working Directories

The default working directory for both new R sessions and new R projects is the user’s home directory (~). You can change this behavior via the session-default-working-dir and session-default-new-project-dir configuration parameters within the rsession.conf config file.

For example, the set the default values to “~/working” and “~/projects” you’d use the following configuration:

/etc/rstudio/rsession.conf

session-default-working-dir=~/working
session-default-new-project-dir=~/projects

You should ensure that users have the permissions required to write to the specified default directories. The specified directories will be automatically created if they don’t already exist.

Note that these settings control only the default working and new project directories (users can still override these settings locally if they choose to).

## 5.7 Workspace Management

### 5.7.1 Default Save Action

When a user exits an R session they need to choose whether to save their R workspace (i.e. .RData file). RStudio has global and per-project settings that control what happens when a workspace has unsaved changes. Possible values are:

• ask – Ask whether to save the workspace file
• yes – Always save the workspace file
• no – Never save the workspace file

The default global setting is ask and the default project-level setting is derived from the current global setting (these options can be modified by end users via the Global Options and Project Options dialogs respectively).

The default global setting can also be changed via the session-save-action-default configuration parameter in the rsession.conf config file. For example, to change the default value to no you would use this:

/etc/rstudio/rsession.conf

session-save-action-default=no

Note that this setting is specified in the rsession.conf config file and takes effect the next time a user launches an R session (rather than requiring a full restart of the server).

### 5.7.2 Suspend and Resume

When R sessions have been idle (no processing or user interaction) for a specified period of time (2 hours by default) RStudio Server suspends them to disk to free up server resources. When the user next interacts with their session it is restored from disk and the user resumes right back where they left off. This is all done seamlessly such that users aren’t typically aware that a suspend and resume has occurred.

#### 5.7.2.1 Session Timeout

To configure the amount of idle time to wait before suspending sessions you can use the session-timeout-minutes setting in the /etc/rstudio/rsession.conf file. For example:

/etc/rstudio/rsession.conf

session-timeout-minutes=360

The default value if none is explicitly specified is 120 minutes.

Important note: this setting and a few others discussed in this section are specified in the /etc/rstudio/rsession.conf file (rather than the rserver.conf file previously referenced).

There are some conditions where an R session will not be suspended, these include:

1. When a top-level R computation is running
2. When the R prompt is not in it’s default state (e.g. during a debugging session)

You can also specify that R sessions should never be suspended by setting the session-timeout-minutes to zero. For example:

/etc/rstudio/rsession.conf

session-timeout-minutes=0

You can also set session timeouts on a per-user or per-group basis, see the User and Group Profiles section for details.

#### 5.7.2.2 Forcing Suspends

You can force the suspend of individual sessions or even all sessions on the server. You can do this directly from the main page of the Administrative Dashboard or from the system shell as follows:

$sudo rstudio-server force-suspend-session <pid>$ sudo rstudio-server force-suspend-all

#### 5.7.2.3 Resume and .Rprofile

By default the Rprofile.site and .Rprofile files are not re-run when a session is resumed (it’s presumed that all of their side-effects are accounted for by simply restoring loaded packages, options, environment variables, etc.).

In some configurations it might be desirable to force the re-execution of profile files. There is an end user option that controls this on the General options pane which defaults to false. However, server administrators may wish to ensure that this option defaults to true. To do this you use the session-rprofile-on-resume-default option. For example:

/etc/rstudio/rsession.conf

session-rprofile-on-resume-default=1

Note that this setting is specified in the rsession.conf config file and takes effect the next time a user launches an R session (rather than requiring a full restart of the server).

#### 5.7.2.4 Child Processes

By default, when sessions are quit or suspended, child processes created in the session will continue to run. You can specify whether or not that should occur by specifying the session-quit-child-processes-on-exit setting in /etc/rstudio/rsession.conf. The allowed values are 1 or 0 to quit child processes or leave them running, respectively.

For example, to quit child processes when the session exits:

/etc/rstudio/rsession.conf

session-quit-child-processes-on-exit=1

Note that this setting is specified in the rsession.conf config file and takes effect the next time a user launches an R session (rather than requiring a full restart of the server). Also, users can specifically override this setting in their project settings.

### 5.7.3 Workspace Storage

Storage of workspaces (.RData files) in RStudio Server does not use compression by default. This differs from the behavior of base R. Compression is disabled because we’ve observed that for larger workspaces (> 50MB) compression can result in much lower performance for session startup and suspend/resume (on the order of 3 or 4 times slower).

The default workspace save options under RStudio Server are as follows:

options(save.defaults=list(ascii=FALSE, compress=FALSE))
options(save.image.defaults=list(ascii=FALSE, safe=TRUE, compress=FALSE))

If you wish to use different defaults you can define the save.defaults and/or save.image.defaults options in your Rprofile.site or per-user .Rprofile and RStudio Server will respect the settings you specify rather than using it’s own defaults.

See https://stat.ethz.ch/R-manual/R-devel/library/base/html/save.html for additional details on how R saves objects and the storage and performance implications of using compression.

## 5.8 First Project Template

### 5.8.1 Overview

RStudio allows you to specify a first project to automatically open for first time users of the system. To do this, set the session-first-project-template-path parameter in rsession.conf to an RStudio project directory. This directory will be copied into the user’s home directory upon first running the IDE, and will automatically open the project contained within. For example:

/etc/rstudio/rsession.conf

session-first-project-template-path=/etc/rstudio/welcome-project

In the example above, the project located within /etc/rstudio/welcome-project would be copied to users’ home directories when first starting RStudio, and the project file welcome-project.Rproj would be run.

The project file must be named the same as the directory it is contained in. For the above example, the project file must be named welcome-project.Rproj. In addition, you must ensure that the project directory is fully readable and executable by your users, as they will be copying the contents of the directory into their home directory.

If you copy an existing project to be used as a project template, ensure that you delete the RStudio metadata folders and files contained within the project directory. You will want to ensure you delete the following:

.Rproj.user .Rhistory .RData

If you are creating the project template for the first time, the project (.Rproj) file must contain the version specifier at a minimum. For example:

welcome-project.Rproj

Version: 1.0

### 5.8.2 Project DefaultOpenDocs

Project files allow you to specify default documents that should be opened when a project is opened for the very first time. For example, you could have your welcome project bring up explanatory documents to help guide your users. To do this, add the DefaultOpenDocs line to the .Rproj file. For example:

welcome-project.Rproj

Version: 1.0
DefaultOpenDocs: welcome.txt:firstMarkdown.rmd

The DefaultOpenDocs parameters specifies a list of files to automatically be opened when the project is opened for the first time, separated by a : character. These files are relative paths to the project directory. Only files contained within the project directory can be opened.

## 5.9 Project Sharing

### 5.9.1 Overview

Project Sharing is a feature of RStudio Server Pro that enables users to work together on RStudio projects. When enabled, a project owner may select any number of other RStudio Server users as project collaborators. RStudio Server manages the permissions of files in the project to ensure that all collaborators can access them, enables multiple collaborators to edit a file simultaneously, and lets collaborators see who else is working inside a project with them.

### 5.9.2 Prerequisites

#### 5.9.2.1 Access Control Lists

To use Project Sharing, the directories hosting the projects to be shared must be on a volume that supports Access Control Lists (ACLs). RStudio Server uses ACLs to grant collaborators access to shared projects; ordinary file permissions are not modified.

Instructions for enabling ACLs vary by Linux distribution and filesystem type (see the Guide to enabling ACLs on Ubuntu or RedHat, for example). Broadly, you will need to ensure that the filesystem is mounted with the user_xattr and acl attributes, and modify /etc/fstab if necessary to persist the attributes.

Note that many Linux distributions now have ACLs enabled by default in which case no special configuration is required. You can use the tune2fs command to inspect the attributes with which your filesystem is mounted (user_xattr and acl are required for project sharing).

#### 5.9.2.2 Project Sharing and NFS

If you plan to use Project Sharing with NFS-mounted volumes, there are several caveats you should be aware of.

1. We recommend mounting NFS with the noac mount option. Without this option, NFS caches file attributes, so it may not be possible for users working simultaneously in a project to know whether they’re seeing each others’ latest changes. The noac option does reduce performance, however, so we recommend testing to choose the right trade off for your environment.

2. Some features which automatically update when directory contents change will not update on NFS. For instance, users may need to manually refresh the Files pane to see new files added by collaborators.

3. ACL support on NFS is more complicated than ACL support on local file systems. Read ACLs on Linux NFS for a discussion of the issues; guidance for configuring specific NFS versions is provided below.

##### 5.9.2.2.1 Determining NFS Version

Project Sharing works with versions 3 and 4 of the NFS protocol. However, some additional configuration may be necessary depending on the NFS version and underlying filesystem. To determine your NFS client version, run the following command on your RStudio Server Pro instance:

\$ nfsstat -m

You should see vers=3.0 in the output if you’re using NFSv3, and vers=4.0 if you’re using NFSv4. Extra RStudio configuration is required for NFSv4 clients (see below).

##### 5.9.2.2.2 NFSv3

When using version 3 of the NFS protocol, the volume must be mounted with the acl mount option. On most systems this is the default, so you need only ensure that noacl is not present. It’s also necessary for the file system on the NFS server to itself be appropriately configured for ACL support; see the section above on Access Control Lists for guidance. Not all file servers that support the NFSv3 protocol also support POSIX compatible ACLs.

To test for POSIX compatible ACLs, you can use the setfacl command as follows:

setfacl -m u:user2:x /home/user1/project

where /home/user1/project is the full path to a directory owned by user1, and user2 is another valid user on the system.

##### 5.9.2.2.3 NFSv4

Version 4 of the NFS protocol uses a very different permissions and ACL model from Version 3. Not all NFSv4 servers support or expose the NFSv4 ACL model, so check with the server administrator to determine whether the capability exists and/or can be enabled.

NFSv4 ACLs differ from NFSv3 ACLs in that they associate a domain with each user named in the access control list. This is typically the same as the domain part of the machine’s host name, but can be any string that the NFSv4 client and server agree on. On Linux systems, the domain can be set in /etc/idmapd.conf.

In order to use NFSv4 with Project Sharing, you must tell RStudio the NFSv4 domain you want to use, as follows:

/etc/rstudio/rsession.conf

nfs4-domain=mydomain.com

This setting both enables NFSv4 support and sets the domain. If this setting is not present, RStudio will only use NFSv3 ACLs.

To test NFSv4 ACL support, you can use the nfs4_setfacl command as follows:

nfs4_setfacl -a A::user2@domain:rax /home/user1/project

where /home/user1/project is the full path to a directory owned by user1, user2 is another valid user on the system, and domain is your system’s user domain.

#### 5.9.2.3 LDAP and sssd

If you’re using sssd with LDAP, you may need to enable user enumeration so that RStudio Server Pro can search the directory to create a list of users you can share a project with. To do this, set the following in your sssd.conf file:

[domain/<domainname>]
enumerate = true

Alternatively, the auth-required-user-group setting can be used. This setting allows RStudio Server Pro to enumerate only the members of the named groups rather than the entire user directory. Therefore, if you cannot enable user enumeration on your LDAP provider, you can instead create a group containing all RStudio users and supply it as the auth-required-user-group.

#### 5.9.2.4 Shared Storage

To use Project Sharing, a directory must be specified to which all users on the server can read and write. In a single-server installation, RStudio uses this location by default:

/var/lib/rstudio-server/shared-storage

In a load-balanced configuration, however, RStudio does not provide a default, so it is necessary to provision a path both visible to and writeable by all users on the system (typically on the same filesystem on which home directories are mounted). This path can be supplied to RStudio Server via the server-shared-storage-path option, for example:

/etc/rstudio/rserver.conf

server-shared-storage-path=/shared/rstudio-server/shared-storage

The server-shared-storage-path option (described above) configures the path used for shared project storage. Note that this storage contains only links to shared projects, not the projects themselves, so requires a very small amount of physical storage.

#### 5.9.2.5 Proxy Settings

If you are running RStudio Server with a proxy, you’ll need to make sure that your proxy is correctly configured to pass websocket connections through in order for all Project Sharing features to work. See the Running with a Proxy section for more on this.

### 5.9.3 Disabling Project Sharing

Project Sharing is enabled by default however you can disable it using the server-project-sharing option, for example:

/etc/rstudio/rserver.conf

server-project-sharing=0

## 5.10 Package Installation

You can customize the location of user packages installed from CRAN as well as the default CRAN repository. You can also configure the user-interface of the RStudio IDE to discourage end-user package installation in the case where packages are deployed centrally to a site library.

Important note: The settings discussed in this section are specified in the /etc/rstudio/rsession.conf file (rather than the rserver.conf file previously referenced).

### 5.10.1 User Library

By default R packages are installed into a user-specific library based on the contents of the R_LIBS_USER environment variable (more details on this mechanism are here: http://stat.ethz.ch/R-manual/R-devel/library/base/html/libPaths.html).

It’s also possible to configure an alternative default for user package installation using the r-libs-user setting. For example:

/etc/rstudio/rsession.conf

r-libs-user=~/R/library

One benefit of establishing an alternative default user library path is that by doing this you can remove the R version component of the package library path (which the default path contains). This makes it possible to upgrade the major version of R on the server and have user’s packages continue to work.

### 5.10.2 Discouraging User Installations

It may be that you’ve configured RStudio Server with a site package library that is shared by all users. In this case you might wish to discourage users from installing their own packages by removing the package installation UI from the RStudio IDE. To do this you use the allow-package-installation setting. For example:

/etc/rstudio/rsession.conf

allow-package-installation=0

Note that this setting merely discourages package installation by removing user-interface elements. It’s still possible for users to install packages directly using the utils::install.packages function.

### 5.10.3 CRAN Repositories

RStudio Server uses the RStudio CRAN mirror (https://cran.rstudio.com) by default. This mirror is globally distributed using Amazon S3 storage so should provide good performance for all locales. You may however wish to override the default CRAN mirror. This can be done with the r-cran-repos settings. For example:

/etc/rstudio/rsession.conf

r-cran-repos=http://cran.at.r-project.org/

Whatever the default CRAN mirror is, individual users are still able to set their own default. To discourage this, you can set the allow-r-cran-repos-edit settings. For example:

/etc/rstudio/rsession.conf

allow-r-cran-repos-edit=0

Note that even with user editing turned off it’s still possible for users to install packages from alternative repositories by directly specifying the repos parameter in a call to install.packages.

## 5.11 Feature Limits

RStudio Server has a number of other limits that can be configured. This section describes these limits. Note that these settings are specified in the /etc/rstudio/rsession.conf file (rather than the rserver.conf file previously referenced).

Besides the limits on package installation and CRAN repository editing described in the previous section there are a number of other limits that can be specified. The following describes all of the options that can be used to limit features.

/etc/rstudio/rsession.conf

allow-vcs

allow-vcs-executable-edit

Allow editing of the underlying Git or SVN executable.

allow-package-installation

Allow installation of packages using the Packages Pane (note that even if this is set to 0 it’s still possible to install packages using utils::install.packages from the command line).

allow-r-cran-repos-edit

Allow editing of the CRAN repository used for package downloads (note that it’s still possible to specify an alternate repository using the repos parameter of utils::install.packages).

allow-shell

Allow access to the Tolls -> Shell dialog (note that it’s still possible to execute shell commands using the system function).

allow-file-downloads

allow-file-uploads

allow-external-publish

Allow content to be published to external (cloud) services. This includes publishing HTML documents created with R Markdown or R Presentations to RPubs (http://rpubs.com), and publishing Shiny applications and documents to ShinyApps.io (http://shinyapps.io). Note that this just removes the relevant user interface elements in the IDE, and that it may still be possible for users to publish content using the R console.

allow-publish

Allow content to be published. If specified, this option removes all user interface elements related to publishing content from the IDE, and overrides allow-external-publish.

All of these features are enabled by default. Specify 0 to disable access to the feature.

Note that these options should be specified in the /etc/rstudio/rsession.conf configuration file (rather than the main rserver.conf configuration file).

### 5.11.2 Maximum File Upload Size

You can limit the maximum size of a file upload by using the limit-file-upload-size-mb setting. For example, the following limits file uploads to 100MB:

/etc/rstudio/rsession.conf

limit-file-upload-size-mb=100

The default behavior is no limit on the size of file uploads.

### 5.11.3 CPU Time per Computation

If you want to prevent runaway computations that consume 100% of the CPU you can set the maximum number of minutes to allow top-level R computations to run for using the limit-cpu-time-minutes setting. For example:

/etc/rstudio/rsession.conf

limit-cpu-time-minutes=30

This specifies that no top level computation entered at the R console should run for more than 30 minutes. This constraint is implemented by calling the R setTimeLimit function immediately prior to handing off console commands to R. As a result it is possible for a particular script to override this behavior if it knows that it may exceed the threshold. This would be done as follows:

setTimeLimit(cpu = Inf)
# Long running R code here...

### 5.11.4 XFS Disk Quotas

If your system uses the XFS file system (http://en.wikipedia.org/wiki/XFS) then RStudio Server can be configured to notify users when they come close to or exceed their disk quota. You can enable this using the limit-xfs-disk-quota setting. For example:

/etc/rstudio/rsession.conf

limit-xfs-disk-quota=1

The user’s XFS disk quota will be checked when the RStudio IDE loads and a warning message will be displayed if they are near to or over their quota.

Administrators can broadcast notifications to user sessions in real-time using the notifications.conf file located at /etc/rstudio/notifications.conf. This file comes by default with commented out entries that you can uncomment and use, and helps show you the available time and message formats.

Each session monitors for changes in the notifications.conf file, and if a new notification is detected, it will be shown to the user at the appropriate time (as defined in the next section). All open sessions for a user will receive the notification, and they will continue to see the notification in any new sessions they open until the notification is acknowledged.

Modifying a notification will cause it to count as a new notification, so make sure to only save changes to the file when you’ve confirmed what you want the message to be and what time it should be displayed. Otherwise, the same message could be shown multiple times.

The notifications.conf file is a file consisting of multiple notification entries separated by a blank line. The following table lists the fields that are available for each notification entry in the file.

 StartTime The start time at which the notification can start to be delievered. This must be a time-formatted field. This field is not required. EndTime The end time at which the notification will no longer be delivered. This must be a time-formatted field. This field is required. Message The message content to show to the users. The message cannot have empty lines in it. This field is required.

An example notifications.conf file is shown below. For more information on the formatting of each field, see the subsequent sections.

StartTime: 2017-08-30 12:00:00 -5:00
EndTime: 2017-08-30 20:00:00 -05:00
Message: Please remember to shut down your computers at the end of the day.

StartTime: 2017-05-30 13:55
EndTime: 2017-06-13
multiple lines by indenting the next line's message text.
Empty lines are not supported!

It is important that each entry consists of 2-3 fields as specified above (StartTime, EndTime, and Message). Each field must go on its own line. There should be no empty lines between field definitions.

For example, this is okay:

StartTime: 2017-08-30 12:00:00 -5:00
EndTime: 2017-08-30 20:00:00 -05:00
Message: Please remember to shut down your computers at the end of the day.

But this is not:

StartTime: 2017-08-30 12:00:00 -5:00

EndTime: 2017-08-30 20:00:00 -05:00

Message: Please remember to shut down your computers at the end of the day.

There must be one empty line (2 new line characters) in between separate notification entries.

For example, this is okay:

StartTime: 2017-08-30 12:00:00 -5:00
EndTime: 2017-08-30 20:00:00 -05:00
Message: Please remember to shut down your computers at the end of the day.

StartTime: 2017-08-30 12:00:00 -5:00
EndTime: 2017-08-30 20:00:00 -05:00
Message: Remember to drop off any borrowed equipment at Grace's office today only.

But this is not:

StartTime: 2017-08-30 12:00:00 -5:00
EndTime: 2017-08-30 20:00:00 -05:00
Message: Please remember to shut down your computers at the end of the day.

StartTime: 2017-08-30 12:00:00 -5:00
EndTime: 2017-08-30 20:00:00 -05:00
Message: Remember to drop off any borrowed equipment at Grace's office today only.

#### 5.12.1.1 Time format

The time format fields, StartTime and EndTime, must be in one of the following formats:

YYYY-MM-DD

YYYY-MM-DD hh:mm

YYYY-MM-DD hh:mm:ss zh:zm

The following table shows the meaning of the format sections.

 YYYY 4 digit year (example: 2017) MM 2 digit month (example: 06) DD 2 digit day (example: 28) hh 2 digit hours (24 hour clock. example: 19) mm 2 digit minutes (example: 15) ss 2 digit seconds (example: 59) zh Time zone hours offset (example: -06 for CST or -08 for PST) zm Time zone minutes offset (usually just 00, different for only a few timezones)

If no time is specified, the time will be set to 00:00:00 in the current server time zone for start times and 23:59:59 in the current server time zone for end times.

If no seconds are specified, they will be set to 00 and the time is interpreted in the current server time zone.

Note that if you have sessions spanning multiple servers in different time zones and you want your notifications to display at a uniform time, you MUST manually set the timezone to what is appropriate. Otherwise, sessions in different time zones will see notifications in their local time.

The following table shows some example dates and how they would be formatted.

 January 1st, 2020 at 6:00 PM in the server’s time zone 2020-01-01 18:00 July 31st, 2018 at midnight in the server’s time zone (for a start time) 2018-07-31 September 23rd, 2019 at 23:59:59 in the server’s time zone (for an end time) 2019-09-23 November 30th, 2020 at 15:14:12 in Pacific Standard Time 2020-11-30 15:14:12 -08:00

#### 5.12.1.2 Message format

The message to deliver must be plain text and cannot have any empty lines. To start text on another line, simply indent the line as in the multiline example in the previous section.

## 5.13 RStudio Connect Server

Users on RStudio Server Pro can publish content to RStudio Connect. To do so, they must first specify the RStudio Connect server they wish to use. You can set the default RStudio Connect server URL to use when users are connecting to an account. To do so, use the default-rsconnect-server option:

/etc/rstudio/rsession.conf

default-rsconnect-server=http://connectserver/