Hey all :wave: Is it possible to pass host env var...
# general
a
Hey all 👋 Is it possible to pass host env vars to pants commands executed through pantsd? I'm using an executable as a pants external tool and the binary is downloaded from S3. If I run my pants command with
--no-pantsd
the file is downloaded from S3 and it works fine, however, without the
--no-pantsd
flag, I get an error
IntrinsicError: Client error (403) downloading file
. Digging on the S3 download handler I've noticed that the
AWS_PROFILE
env var is not present when pants is running through pantsd, and therefore the AWS credentials are not correctly loaded to download the file, so I'm wondering if it would be possible to have
AWS_PROFILE
when pants is running through pantsd?
b
Hmmm, maybe @bitter-ability-32190 knows how to get this working?
b
Nothing comes to mind other than ensuring the daemon was started with the env var set. I forget which config setting allows you to add those 🤔
a
I tried to find an
extra_env_vars
option or something similar like we have on some subsystems but didn't find anything. Also setting the env var inline with the command doesn't seem to work, e.g.
AWS_PROFILE=foo pants lint ::
.
On my custom plugin I did a simple
<http://logger.info|logger.info>(os.environ)
and it looks like I only have
HOME
,
USER
,
PATH
and
__PANTS_BIN_NAME
, so I'm assuming the pantsd process only have these preserved env vars? When I run commands with
--no-pantsd
I have all my host env vars available on
os.environ
. I didn't find a way to tell pantsd to forward other host env vars to its process, e.g.
AWS_PROFILE
. Is this currently not an option?
b
There's a chance it doesn't work, and I only ever loaded AWS stuff from the config on disk. I no longer work at that job, so memory is fuzzy
b
Potentially these values should be passed through from the client? Rather than inherited from pantsd' environment? (thanks for filing https://github.com/pantsbuild/pants/issues/21168 btw)
a
I think that would also work. In this case we could have an option somewhere to define which env vars should be passed through from the client? Possibly a global option? I've seem we have other
pantsd_*
global options, right?
b
Yeah I think thats the best solution. That way we don't invalidate the daemon too often unless we have to