https://pantsbuild.org/ logo
#general
Title
# general
f

freezing-lamp-12123

11/04/2022, 7:55 AM
is it well known/documented that if you have a flag
--env
on a subsystem that there’s some hidden default which is all environment variables ? — if i add with a string default, the current value seems to be the full dump of my environment 😂
Copy code
PANTS_MY_SUBSYSTEM_ENV
  env
      default: my-default
      current value: namespace(__CFBundleI ..... continues with a full dump of my environment)
there seems to be a “hidden” default somewhere? if i actually set it with
Copy code
./pants my-subsystem --env=foobar
i get this …
Copy code
default: my-default
      current value: foobar (from command-line flag)
          overrode: namespace(FNM_DIR='/Users ... full dump of env vars)
h

happy-kitchen-89482

11/04/2022, 2:52 PM
I'm pretty surprised by this. What's an example of such a subsystem?
Some quick grepping did not find any options named
--env
Is this happening in a custom subsystem of yours, sounds like?
f

freezing-lamp-12123

11/04/2022, 9:19 PM
yes, custom one — i have an StrOption field and it seems to be the case when:
env = StrOption(….)
or
my_env = StrOption(flag_name=“--env” …)
h

happy-kitchen-89482

11/05/2022, 12:13 AM
huh………
I will try and reproduce
f

freezing-lamp-12123

11/05/2022, 7:00 AM
2.14.0
h

happy-kitchen-89482

11/05/2022, 7:56 AM
Welp, it’s true!
oh….
yep
That is so env vars can be interpolated in config files, but evidently it is leaking into the option values
💡 1
Will put a fix together
🙏 1
This is an amazing bug! So so weird
“I picked this perfectly reasonable name for my option, and all hell broke loose”
😂 1
f

freezing-lamp-12123

11/05/2022, 4:11 PM
yup :)
i have a knack for breaking anything
h

happy-kitchen-89482

11/05/2022, 4:14 PM
I mean, you just tapped on the glass, we put the cracks in it to begin with
this also manifests with “user”, “homedir” and “buildroot” - all the things we interpolate
f

freezing-lamp-12123

11/05/2022, 4:15 PM
🤦‍♂️
h

happy-kitchen-89482

11/05/2022, 4:26 PM
FWIW this is a legacy of the old pants.ini. In the Python .ini format, you can interpolate values from the DEFAULT section. So we injected these seed values into the DEFAULT section to make them available for interpolation. And we kept the same paradigm when we switched to pants.toml, even though DEFAULT is not an intrinsic feature of toml.
The problem occurs because the original purpose of DEFAULT is to provide the default values for other sections, and we were abusing it…
However now that we’re fully on TOML, and we implement the interpolation ourselves instead of delegating it to Python’s ini library, there is no reason to use the DEFAULT section for seeding, we can keep the seed values in some separate dict
This is some real railroad gauge stuff
good find!
f

freezing-lamp-12123

11/05/2022, 4:59 PM
adventurous 😄
thanks for digging into the weeds so quickly
h

happy-kitchen-89482

11/05/2022, 6:07 PM
Thanks for the bug report!
Would you mind filing a bug report for this at https://github.com/pantsbuild/pants/issues/new/choose ? That way we have a persistent record of this story. Slack is ephemeral, and this convo will be lost in 3 months…
👍 1
f

freezing-lamp-12123

11/07/2022, 10:38 AM
4 Views