sudospawner icon indicating copy to clipboard operation
sudospawner copied to clipboard

Add env param to Subprocess call

Open ssatia opened this issue 7 years ago • 5 comments
trafficstars

I noticed an issue wherein the c.Spawner.environment setting in the JupyterHub config was not being used when spawning the new process. It seems to be so because we are not passing the env to the Subprocess function.

I hope this request can be merged soon and a new release could be created shortly thereafter.

ssatia avatar Jun 30 '18 02:06 ssatia

Checking back in on this, cc @minrk

ssatia avatar Jul 18 '18 16:07 ssatia

Hi, thanks for the PR! I think this is not the right fix. env in the subprocess command sets the environment for the mediator process, which is not the notebook server process that Spawner.environment should set. This is relayed via passing the args and env fields through the mediator. This is passed to the mediator here and from the mediator to the real process here. I opened #53 to enable some testing, which should include verification that Spawner.environment is indeed passed on to the notebook process.

How are you setting the environment and what are you seeing as a result?

minrk avatar Jul 18 '18 19:07 minrk

I am setting up the PYTHONPATH in the JupyterHub config under c.Spawner.environment. I have listed the config items related to SudoSpawner below:

c.JupyterHub.spawner_class = 'sudospawner.SudoSpawner'
c.SudoSpawner.sudospawner_path = '/path/to/script'
c.Spawner.environment = {
    'PYTHONPATH': '/some/path/'
}

However, I find that it is not set in the notebook env on the spawned server.

ssatia avatar Jul 25 '18 17:07 ssatia

Checking back in on this, cc @minrk

ssatia avatar Aug 03 '18 20:08 ssatia

@minrk are there any updates on the testing process?

ssatia avatar Aug 22 '18 18:08 ssatia

6 years late is better than never :)

@ssatia the behavior you are seeing is because PYTHONPATH is intentionally not allowed to be set this way - see https://github.com/jupyterhub/sudospawner/blob/adc6298ddf2329bf50161178c91c87c54c637568/sudospawner/mediator.py#L90.

With that, I'm going to close this PR.

yuvipanda avatar Jun 11 '24 23:06 yuvipanda