I have a team member trying to access some environ...
# general
b
I have a team member trying to access some environment variables within pytest code but we're unable to find the environment variables inside of the sandbox that 1.30 operates in. Is there a way to do something like
export PANTS_PYTEST_VAR1=test
and have the python code see that env var?
I see that 2.12 added some neat functionality which is a goal to upgrade to, but hoping there's a simple solution for 1.30 while we work through the upgrade to 2.12
e
It looks like the option is
--test-extra-env-vars
(Or pants.toml it with
[test] extra_env_vars = [ ... ]
): https://github.com/pantsbuild/pants/blob/674df55a3dda870e78997965e617993b9d10d2eb/src/python/pants/core/goals/test.py#L195-L244
That's if using v2 rules, The v1 handling should just let env vars be read without any configuration.
b
this would be using v2
e
Ok, that should do it then. And it looks like that's still the same setting in modern Pants 2.x.
b
I tried
./pants test --test-extra-env-vars VAR=v target::test
and pants told me that
--extra-env-vars
was not recognized.
e
How about
./pants test --extra-env-vars VAR=v target::test
?
Ah, right. You need
=
😕
./pants test --extra-env-vars=VAR=v target::test
All pants flags unfortunately need
=
b
Oddly enough this is the help advanced menu
I would've expected it to list the global options too
e
./pants --v2
right? You said you were using
--v2
?
b
Yeah, I have v1 disabled in the pants.toml file
e
What is the exact Pants version?
b
1.30.0
e
Try 1.30.4 or 1.30.5rc1.
Those are 2 latest 1.30.x
The code I linked was 1.30.x HEAD.
Looks like backported to 1.30.2rc0 (9/23/2020)
b
Oh gotcha, i'm trying .4 right now to see if that works better
Yeah, .4 looks like it will have that extra arg like you mentioned. I'll give it a go!
Sweet, that let me pass through the a dummy env var, I can easily add what I actually need from there. Thanks!