Closed robkooper closed 3 years ago
@cboettig has riffed on this before---apparently pruning the existing environment is simply what RStudio does :-/
Hey @robkooper ,
yup, like Dirk says, RStudio decided that the server should pay no attention to the system env vars. Could be a security thing (note we do put PASSWORD in an env var, which at least in a multi-user setting you may not want to expose to the R session) but iirc it is just because it gives them a more consistent environment to troubleshoot. As you discovered, you'll have to write any env var you want to expose to RStudio into an Renviron
. We usually append to $R_HOME/etc/Renviron
in our dockerfiles, but writing to the user's .Renviron
is fine too.
of course anything running in cli R instead of RStudio doesn't have this issue.
In the PEcAN project we leverage of these docker images for our R and RStudio needs. We install additional packages, and will start RStudio. Some our code depends on environment variables that we inject into the container, for example we pass in the URI for RabbitMQ as an environment variable. Unfortunately it seems that somewhere these are removed and when in the RStudio we do
Sys.getenv("RABBITMQ_URI")
it will return "".I tried setting S6_KEEP_ENV=1 but that did not work. Right now I'm using the following solution that works:
Use an environment variable called
KEEP_ENV
that lists all environment variables to preserve for RStudio, and the following script:Let me know if there is an easier way to enable me to store environment variables for use in RStudio.