Jupyter-rsession-proxy and environmental variables

I have a Z2JH deployment that uses jupyter-rsession-proxy with config custom URL, /rstudio to drop users directly into RStudio when they log in. This is magically nice for our R users.

Unfortunately, RStudio does not respect global environmental variables unless they are written into an Renviron file (e.g. $R_HOME/etc/Renviron.site).

I have some environmental variables I can define in my hub config (KubeSpawner.environment), e.g. such as the app id for the wonderful gh-scoped-creds plugin. This works wonderfully in the standard jupyterlab interface, but because this env var is not echoed into an Renviron, it is not visible to RStudio and users can’t leverage gh-scoped-creds.

Is there a way to get RStudio to see these env vars? I know I can manually hack around this by editing the ~/.Renviron from /lab endpoint to contain the env var, but that’s really not a nice solution to ask my users to do.

Its possible to mount small config files via z2jh’s singleuser.extraFiles, but it needs to be outside the user home directories that are also mounted i think.

If you declare config filename and content, and the files location, it can be mounted for all users via singleuser.extraFiles as long as its outside their home folders quite easily.

Thanks, this is a good idea, but is there no way to have a file injected into the user home folder?

RStudio will read environmental variables from the $R_HOME/etc/Renviron.site outside of the user’s home directory, but typically this file is already being provided by the container, so mounting it as an extraFiles will overwrite the environmental variables set by the user’s container for RStudio, which is not a good idea.

Maybe there’s a trick with some other config file I could monitor, but I’m not sure. I don’t know much about the startup routine when a server is launched – does it always source scripts in say /etc/profile.d ?

Otherwise maybe I can follow up with the jupyter-rsession-proxy maintainers about this. (In the rocker project, we propagate most environmental variables set at runtime into the Renviron.site, rocker-versioned2/scripts/init_set_env.sh at 26c50e561ae4b10386b9f7adaa37a77b52f7f5d6 · rocker-org/rocker-versioned2 · GitHub, but this relies in the s6-init service that brings up the rserver session and is not in use by jupyter-ression-proxy…)