JupyterLab startup scripts/hooks?

I’m wondering if there is any way to do something analogous to .bashrc for the jupyterlab environment itself?

I’m interesting in setting a handful of environment variables, PATH, PYTHONPATH, R_LIBS_SITE, etc.

For the things specific to the terminal I can use .bashrc, and for R stuff I can use .Rprofile/.Renvironment, for Python notebooks I can use .ipython/profile_default/startup, etc.

It would be nice if there was a way to just source or run a script on lab startup that would do all this in one place :slight_smile:

Following up, it appears that .bashrc is not sourced by jupyter on start, but .profile is (or should be?) https://github.com/jupyterhub/jupyterhub/issues/2011

I ended up putting my various environment setup into /etc/profile (actually, I added source /some/admin/editable/config to /etc/profile) and this seems to do the trick.

Except for RStudio, which really doesn’t like inheriting environment variables or running profile scripts; the RStudio docs mention /etc/rstudio/rsession-profile, but I think this is only available for the Pro version. Adding specific environment vars to /opt/conda/lib/R/etc/Renviron (or wherever Renviron lives) is the best I’ve found so far.