Setting custom environment variables through Systemd Spawner

193 views
Skip to first unread message

Mark Holliman

unread,
Nov 3, 2017, 7:28:08 AM11/3/17
to Project Jupyter

How can I setup custom environment variables for notebooks spawned using th= e systemd spawner?  I would like to be able to edit PYTHONPATH and run a fe= w EUPS setup commands to initialize an environment when a notebook spins up= . =20

 

c.SystemdSpawner.extra_paths only allows editing the PATH variable.

c.Spawner.environment[] and c.Spawner.env.update({}) aren't supported by th= e systemd spawner. =20 c.Spawner.env_keep isn't a viable option, as I have Jupyterhub running as r= oot and it needs a different environment.

 

I've tried creating a custom c.Spawner.cmd but this hasn't worked either.  = It looks like this:

#!/bin/bash

export PATH=3D'/opt/anaconda/bin:/opt/eups/bin:$PATH'

source /opt/lsst_stack/loadLSST.bash

source activate lsst

setup lsst_sims

exec jupyterhub-singleuser "$@"

 

But when I check the environments on the spawned notebooks they do not appe= ar to inherit the environment variables set by those commands.

 

I've also tried setting the environment variables in the .bashrc files for = each user, but these appear to be ignored by the notebooks spawned through = systemd (the notebooks only pickup the environment from the root user).

 

Cheers,

  Mark Holliman

Darkfish Tech

unread,
Jul 23, 2019, 9:01:07 PM7/23/19
to Project Jupyter
G'day mate,

Did you manage to find a solution to this problem? I am in exact same shoes as you and wouldn't want to have same env as root.

Cheers
Reply all
Reply to author
Forward
0 new messages