-
Notifications
You must be signed in to change notification settings - Fork 11
Description
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:
- run a command that sets up /spfs and some env vars
- run
spk env ...inside that first environment (because you want to try something), which "replaces" /spfs but leaves those env vars - run a command that uses those key env vars, but because it also expects the first /spfs' contents it fails/errors
- 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.