Setting Environment Variables in Posit Workbench



The following methods can be used if you need to set an environment variable that will populate across your R session, VS code, Jupyter Notebook & JupyterLab Sessions.


Method 1:

You may specify environment variables to set when creating launcher sessions.

To specify environment overrides, modify the /etc/rstudio/launcher-env file to consist of multiple environment entries separated by a blank line. see details here.

An example /etc/rstudio/launcher-env file is shown below.



Method 2: 

In the example below, we'll configure a proxy environment variable using a Linux feature to apply it across all sessions. 

1. Create a script in the  /etc/profile.d  directory, for example:


touch /etc/profile.d/
chmod 755 /etc/profile.d/


2. Modify the to contain the environment variables you wish to set.  Example 
 /etc/profile.d/ Contents:

export https_proxy=https://proxyURL
export http_proxy=http://proxyURL


3. Once this is set, restart the services:

rstudio-launcher restart
rstudio-server restart


If the issue persists, feel free to open a support ticket here: