-
Notifications
You must be signed in to change notification settings - Fork 86
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Rstudio does not respect environment variables initiated during login shell. #135
Comments
Thank you for opening your first issue in this project! Engagement like this is essential for open source projects! 🤗 |
I tried setting variables in ~/.Renviron in different spawning environments (kubespawner, batchspawner) on two separate hubs and both were available within the RStudio console. As far as I know, jupyter-rsession-proxy cannot alter this behavior. However can you elaborate on
That sounds like you're doing something different than vanilla |
Yes we wish to do something a bit different than hardcoding the variables. i.e setting: PATH=${PATH} in .Renviron, so that we can build the variables during the login (scripts in /etc/profile.d) and pull them into R. We've been able to do this just fine in the R console within JupyterHub, but not with Rstudio. Our current scheme spawns a "jupyterhub-singleuser" via a script that uses a shebang with the option "-l" which starts a login shell. This sources the user's profile before opening Juptyerhub and allows for the generation of variables, functions, aliases, etc. We can then dereference those variables in .Renviron so that they do not have to be hardcoded. This scheme works fine when spawning an R kernel in Jupyterhub, but not when spawning an Rstudio instance. |
Just trying to follow this example, you define things like PATH in /etc/profile.d/, but if you do not set PATH in .Renviron, RStudio won't inherit it from the shell environment? Do you know if this also works with RStudio outside of jupyterhub + jupyter-rsession-proxy ? |
Correct, I believe R only creates variables that are set in .Renviron. I.e. if you have a shell variable TEMP="test" and you do not set TEMP=${TEMP} in .Renviron, then Sys.getenv("TEMP") will return a null value in an R instance. |
I see this spot in your code which I'm assuming is where the environment is stripped down to just the specific things listed below?:
|
That code does set some environment variables, but it should not unset everything else. jupyter-server-proxy integrates those variables into the existing environment. I have a feeling this has more to due with the spawner or RStudio and not jupyter-rsession-proxy. However I'm not sure why RStudio is not otherwise picking up your /etc/profile.d/ configuration. According to RStudio's docs, R is started under a bash login shell and should read /etc/profile. |
I think there are major differences between how the open-source Rstudio server and Rstudio server pro configure themselves. You can see the steps you mention boxed out with "pro" here: https://docs.rstudio.com/ide/server-pro/r_sessions/session_startup_scripts.html |
You could shim the rsession executable with a shell script and use that to inject environment variables. Using |
We spawn single user jupyterhub instances by setting the c.Spawner.cmd to a script that initiates a login shell with "!#/bin/bash -l". This allows us to dereference shell variables that were created in .Renviron and we see this works by checking them in R console within JupyterHub. However, this does not work in Rstudio using jupyter-rsession-proxy. Is there any way to solve this issue?
The text was updated successfully, but these errors were encountered: