Skip to contents

Notes for the System Administrator of a Multi-User blaseRtemplates Environemnt

The blaseRtemplates environment works well for a multiuser system running Rstudio server. In fact it was designed for this purpose. Here are the steps you need to perform to set this up:

  1. Run blaseRtemplates::establish_new_bt() but make sure the cache_path parameter points to a directory that is/will be available to all of your users. The project_path parameter can point to your own workspace.
  2. Go to $R_HOME/etc. Replace Rprofile.site with the contents of the .Rprofile generated in the cache directory.
  3. In the same directory, add the lines from the .Renviron file generated by establish_new_bt() to the Renviron.site file. You may need to have other things in there so don’t overwrite the whole file.
  4. Create an empty directory “user_name” within the user_project library directory of the cache. This should get populated when the user starts making projects.
  5. Since the other users will not be running establish_new_bt(), they won’t have a baseproject. You need this to provide functionality for the users if/when they get out of a project. Bad things happen when they are not working in a valid project. So you need to move your baseproject to the cache directory and edit the new Rprofile.site file to point all of the users to that. You can do the latter by replacing the tryCatch statement in the beginning of the .First function with this (note the path you need to edit in the third-to-last line):
# always be working within a project
tryCatch({
  usethis::proj_activate(usethis::proj_get())
  cat("\n")
},
error = function(cond) {
  .libPaths(c(fs::path(
    Sys.getenv("BLASERTEMPLATES_CACHE_ROOT"),
    "user_project",
    Sys.getenv("USER"),
    "baseproject"
  ),
  .libPaths()))
  usethis::proj_activate("/path/to/baseproject")
  cat("\n")
})
  1. Edit your sudo crontab file by running sudo crontab -e and include something like this:
* * * * * chmod -R 777 /path/to/cache_R_4_2/library

This will set 777 permissions on the package library. This way all of your users can read and write to the library. If you want more security you can tweak the permissions and group settings, but this can be tricky to maintain because of the limitations in the file writing and linking programs used within R. Usually I find the 777 permissions to work well. In normal operations, everything is versioned so your users won’t overwrite anything useful. The only problem is if someone goes in and clobbers the cache from the command line or through the Rstudio file manager either maliciously or by accident. To protect against this you should back up your cache to another drive.

  1. If everything works, when your users log in, they should start out in the baseproject. From there they can make or clone their own projects using the usual functions.

Disclaimer

These operations are not routinely tested with multiple users, so may require some tweaking. However this is basically what we use in production. Please post any issues to the blaseRtemplates issues page.