faint-yak-89693
07/07/2025, 7:52 AMadhoc_tool
rule to build.
However the compiler also needs credentials provided through environment variables, which can be provided using extra_env_vars
, however this parameter seems to also affect the cache, and thus greatly diminishing the benefit of pantsbuild.
Is there any way I can provide credentials through environment variables to adhoc_tool
without having it affect the cache digest?wide-midnight-78598
07/07/2025, 11:38 AMfaint-yak-89693
07/07/2025, 3:36 PMcache_scope
, though I don't see how it would help, if anything it'd do the opposite? Making the cache-scope smaller.faint-yak-89693
07/07/2025, 3:37 PM# Initial run
export AUTH_VAR="VERY_SECRET"
pants export-codegen :main
cat dist/codegen/file.txt
# Gives:
# Authenticated something with credentials: VERY_SECRET
# Now changing the env variable, I'd like the cache to persist, as this
# credential, is just a credential, it doesn't affect the output.
# It either succeeds, or fails, but given it succeeds, the result should be deterministic.
export AUTH_VAR="LESS_SECRET"
pants export-codegen :main
cat dist/codegen/file.txt
# But unfortunately, it now gives:
# Authenticated something with credentials: LESS_SECRET
wide-midnight-78598
07/07/2025, 3:50 PMfaint-yak-89693
07/07/2025, 4:00 PMfaint-yak-89693
07/07/2025, 4:02 PMextra_env_vars
is an input which alters the output, and reruns, if it stays the same, it reuses previous cache. This in a way, is understandable since the env vars could indeed be considered as an input. Though in my case, they aren't, or some vars aren't at least. So would be nice to tweak/configure which env vars actually impact, and which don't.wide-midnight-78598
07/07/2025, 7:44 PMwide-midnight-78598
07/07/2025, 7:45 PMwide-midnight-78598
07/07/2025, 7:45 PMfast-nail-55400
07/07/2025, 8:04 PMwide-midnight-78598
07/07/2025, 8:05 PMworkspace_environment
strip or maintain env vars from the system?fast-nail-55400
07/07/2025, 8:10 PMfast-nail-55400
07/07/2025, 8:10 PMProcess
the Pans rule is trying to run (and as modified by relevant config options).fast-nail-55400
07/07/2025, 8:11 PM.netrc
file or similar.wide-midnight-78598
07/07/2025, 8:13 PMfast-nail-55400
07/07/2025, 8:13 PMfast-nail-55400
07/07/2025, 8:14 PMProcess
but that would likely break remote_environment
fast-nail-55400
07/07/2025, 8:14 PMfast-nail-55400
07/07/2025, 8:14 PMfast-nail-55400
07/07/2025, 8:14 PMfast-nail-55400
07/07/2025, 8:14 PMwide-midnight-78598
07/07/2025, 8:15 PMfast-nail-55400
07/07/2025, 8:15 PMwide-midnight-78598
07/07/2025, 8:15 PMwide-midnight-78598
07/07/2025, 8:17 PMfast-nail-55400
07/07/2025, 8:53 PMProcess
intrinsic rules, so plugins are not going to change that in Python alone.wide-midnight-78598
07/07/2025, 9:07 PMwide-midnight-78598
07/07/2025, 9:08 PMfast-nail-55400
07/07/2025, 9:27 PMexport FOO=BAR
stuff in it and source the file by name and make sure the file is not a dependency of the relevant target.wide-midnight-78598
07/07/2025, 9:28 PMfaint-yak-89693
07/08/2025, 4:25 AM~/.netrc
file outside the sandbox do the same, just being less transparent about it?
As technically, something truely sandboxed, I wouldn't expect to be able to access ~/.netrc
?faint-yak-89693
07/08/2025, 4:25 AM~/.netrc
, it wouldn't copy/send that over to the remote execution, and would just fail? Or is the expected that the remote execution environment simply has credentials configured for all and everything?fast-nail-55400
07/08/2025, 4:28 AM.netrc
would not work with REAPI because a local .netrc
would not work with a remote build execution since it is not installed there. And sending a .netrc
over REAPI means it is part of the input root for a remote execution request and thus part of the cache key.fast-nail-55400
07/08/2025, 4:29 AMAction
and Command
protobufs in the REAPI which carry those env vars are hashed (indirectly) as part of the cache key.faint-yak-89693
07/08/2025, 4:59 AMfast-nail-55400
07/08/2025, 5:21 AMadhoc_tool
et al. for having environment variables which did not contribute to the cache key.
As I mentioned before, this would need to be a change in how Pants executes processes. You would need a way to supply environment variables to the local executor which did not contribute to the cache key which is the hash of most of the Process
dataclass internally in the rules engine. (Note that description is excluded for example from comparisons.) https://github.com/pantsbuild/pants/blob/4abf65d0b989d8c10d995f204076f4e6e25ae87f/src/python/pants/engine/process.py#L106
And designing this needs to take into account how the engine de-duplicates execution requests and only computes the result once per session and/or stores it in the local cache. So it is not just a simple matter of making the env
field on Process
not take part in comparisons.fast-nail-55400
07/08/2025, 5:23 AMexperimental_workspace_environment
as the environment
for the execution. You would then source the file into the shell to get them. This side steps the cache key issue because the environment variables are never set in the Process
dataclass for your adhoc_tool
execution.fast-nail-55400
07/08/2025, 5:24 AMfast-nail-55400
07/08/2025, 5:26 AMfaint-yak-89693
07/11/2025, 8:39 AM~/.netrc
. Whilst the hack you propose may work, I don't see feasible, it's a very complicated solution, to solve a problem which I think the build tool itself should have support for.
While running remote execution is not a priority for me today, It is something I would like to use, how does that work? Surely it will not use my local ~/.netrc
file? does the remote server need to have that file configured? I cannot believe this to be a "new problem"?faint-yak-89693
07/11/2025, 8:41 AMgorgeous-winter-99296
07/11/2025, 12:01 PM