On Linux, how to configure RStudio server to set the location of .local and other user-related directories ?

Dear RStudio Experts,

We have an RStudio server installed on Linux. We have many RStudio users, and their RStudio related directories are all in their respective home directories. However we have limited space in the home filesystem, and hence couldn't hold too much RStudio related directories, for example:

R
.local ==> I noticed that .local could be very big if the user is running big R programs.
etc.

I want to configure R server or RStudio server, so that the these directories could be redirected to a different filesystem where there is enough space.

I appreciate if you could guide me through the steps of reconfiguring.

Thank you in advance

You can change the environment variable XDG_DATA_HOME either at the OS level or using the method described here: 2 Server Management | RStudio Workbench 1.4.1717-3

Hi rstub,

Thanks for the reply. I followed the instruction in the document, set XDG_DATA_HOME in /etc/rstudio/env-vars (the file was not even existent before I created this time) as follows:

[root@ ~]# cat /etc/rstudio/env-vars
# Store user data on mounted external storage
XDG_DATA_HOME=/data/$USER
[root@ ~]#

And restarted rstudio. However, the session directory is still in ~/.local/share/rstudio/, not moved the new location set in env-vars. I wonder if I miss anything ?

P.S. we use community version RStudio 1.4.1101 on Redhat 7.

[root@ ~]# rstudio-server version
1.4.1106 (Tiger Daylily) for CentOS 7
[root@ ~]#

I appreciate your reply

Did you restart RStudio Server and created a new session? Does the directory /data/$USER exist for the user in question? What is the value of the environment variable XDG_DATA_HOME?

I just tested this with the rocker/rstudio Docker container

docker run --rm -p 8787:8787 -e PASSWORD=<somepassword> \
    -v $(pwd)/cluster/env-vars:/etc/rstudio/env-vars \
    -v $(pwd)/data:/data rocker/rstudio

Here cluster/env-vars is exactly the file you posted above and data/rstudio exists and is owned by uid 1000.

yes, the directory /data/$USER for each user (including myself).
We don't use docker, and hence we directly installed RStudio on Linux. As for XDG_DATA_HOME, how to check that, in which specific configuration file ? P.S., it's a single RStudio server, and we don't have a cluster.

Thanks

Did you restart RStudio Server and created a new session?

Ok, and are these directories owned by each user?

Within the R console you can use Sys.getenv("XDG_DATA_HOME"). In the terminal echo $XDG_DATA_HOME.

yes each user has it's individual /data/$USER directory, i.e. user id bob has /data/bob/, user id tom has /data/tom/, these directories are not shared, rather they are owned by each individual users.

I did restarted Rstudio server after changes.

For XDG_DATA_HOME, I got this from R console:

Sys.getenv("XDG_DATA_HOME").
Error: unexpected symbol in "Sys.getenv("XDG_DATA_HOME")."

The command should read

Sys.getenv("XDG_DATA_HOME")

without the trailing dot.

It gave me an empty result:

Sys.getenv("XDG_DATA_HOME")
[1] ""

The problem seems to be your RStudio Server version. According to the current RStudio Release Notes - RStudio support for /etc/rstudio/env-vars was added in the most recent version 1.4.1717. So it is probably best if you upgrade your installation.

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.