Skip to content

Configurable lists of environment variable names to clear/keep when using spk env #1253

@dcookspi

Description

@dcookspi

We had recent situation where a parent processes' environment variables caused a program run inside a child spk env environment to mess up. The situation was:

> spawn launch sometool       (<--- uses /spfs and sets env vars)
> > spk env anotherpackage    (<--- has its own /spfs, but keeps all the env vars)
> > > spawn snapshot          (<--- uses env vars from the spawn launch and things in /spfs, 
                                    but /spfs isn't what it was)
error: unable to find target  (<--- user is confused because that's not the real problem)   

More generally the problem is:

  1. run a command that sets up /spfs and some env vars
  2. run spk env ... inside that first environment (because you want to try something), which "replaces" /spfs but leaves those env vars
  3. run a command that uses those key env vars, but because it also expects the first /spfs' contents it fails/errors
  4. user is confused

If spk env ... had a way to clear out some environment variables before starting the new /spfs environment, commands run inside would either not use them, or produce a more appropriate error message.

spk env (or spk) could have a configurable list of patterns (e.g. "MYTOOL_*,SOME_VAR,..") for names of env vars to cleared from the env before running spfs run/enter. It could also have a list of names of env vars to keep (e.g. "MYTOOL_THIS_SETTING") to allow exceptions from the clearing. Env vars not in either list would be left as they are. This would let a site configure spk to clear sets of key env vars when entering new spfs environments, or not as they saw fit.

Metadata

Metadata

Assignees

No one assigned

    Labels

    agenda itemItems to be brought up at the next dev meeting

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions