Setting up a Site Library


I am running RStudio Server for a (small) team on AWS. In order to get the others up and running fast & to keep all of us on the same version of "truth" I tried setting up a site package library. However, I cannot seem to make it work.

I tried adding a line R_LIBS_SITE="/home/rpkgs" to the file, located in /etc/R/ but it does not appear as an option to save packages even after reboot.

Any advice how to make this work (or whether there is a better approach to a site library) is much appreciated!

Package binaries under linux

A few hints to follow:

  • Did you create the folfer /home/rpkgs ? I think the folder must exists for R to see it. I am not sure if you can set it in a /home subdirectory but may be. It should be read only access for all. We have one on a shared storage (/mnt/R/lib-site)

  • What are the value of .libPaths(), .Library and in your RSession that load the ?

  • What do you mean by that ? Did you try to install a package in this site library ? you need to indicate the library path, otherwise it will be in the default (first one of .Libpath())
    install.packages('rlang', lib = "/home/rpkgs")

Know that you can also set up an internal cran like repository with miniCRAN and put in this repo only the version of the package you want. Your team has just to install packages from there to be on the same page. (manually, or setting the repos option)


Thanks @cderv or pointing me in the right direction!

For the benefit of posterity:

  • a directory (in fact several) for the site library has been around since install; in our case /usr/lib/R/site-library
  • it was listed in in .libPaths() - and thus did not require any changes in - but was not useable because it was not writeable
  • to make it work it I have set up a group of RStudio users = sudo groupadd rstudio & added users to it sudo adduser jlacko rstudio
  • then I added the path/usr/lib/R/site-library to the newly created rstudio group sudo chgrp rstudio /usr/lib/R/site-library
  • and made it writeable for group members by calling sudo chmod -R g+w /usr/lib/R/site-library

Worked like a charm!



You'll have to take care of this ibrary. If it is writeable by anyone, then anyone can update a library. Could not be intended, but could also cause issues because you cannot update a library if it is in use, and it can be loaded by any user in this case. You'll see how it works. I am curious of your experience after a few month.

We did the same as you but the folder is readable by all users but only a radminusers group can write into it.
We want to manage the library in this folder (which packages and in which version)

Glad you found your answer.


Thanks :slight_smile:

My current situation is a big improvement over each team member having his own user library; I am glad for it.

I will give it a shot - an alternative I also considered was not having the /usr/lib/R/site-library directory group writeable, but making a senior team member (myself, I suppose) owner with responsibility for installing / updating packages.

We will see how it plays out.