Sessions Startup Scripts

When an RStudio Pro Session starts up, the following scripts are run:

  1. Workbench: Any PAM session modules
  2. Workbench: The /etc/rstudio/rsession-profile script
  3. Workbench: The environment module for the R version in use, if any; see Extended R version definitions
  4. Workbench: The prelaunch script for the R version in use, if any; see Extended R version definitions
  5. Workbench: System and user shell profile scripts, such as .bash_profile
  6. Workbench: The R process itself, inside any supervisor specified by rsession-exec-command
  7. .Rprofile and other R initialization scripts; see Initialization at the Start of a Session for details
  8. RStudio Pro-internal session startup scripts
  9. The rstudio.sessionInit hook

The very last of these provides a way to run code after the R Session is fully booted and ready to use; since the RStudio Pro-internal session startup scripts only run in RStudio Pro it can be used to finalize R Sessions in RStudio Pro-specific ways, using for example methods in the rstudioapi package. Here is an example that prints the RStudio Pro version in new RStudio Pro Sessions:

# /opt/R/version/lib64/r/etc/Rprofile.site
setHook("rstudio.sessionInit", function(newSession) {
  if (newSession)
    message("Welcome to RStudio ", rstudioapi::getVersion())
}, action = "append")
Back to top