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

acoustic-garden-40182

05/10/2023, 3:14 PM
Hi everyone. I've tried searching this channel to no avail. I have successfully built a Pex file and have it running in a Docker container with
pants run
. Everything works perfectly. I'm able to pass environment variables in with
--docker-run-args="-e MY_VAR=var123"
, and this also works. However, if I do this
--docker-run-args="--env-file .env"
, assuming that the .env file is in the current working directory, I get the following error:
docker: open .env: no such file or directory.
Is loading environment variables from a file supported by Pants in this case? I'm on version 2.16.0rc1.
c

curved-television-6568

05/10/2023, 3:29 PM
Hi Gary, My guess would be that your
.env
file is not present in the sandbox, meaning there is nothing depending on it to make Pants include it.
oh, hmm.. wait,
run
is interactive, so the sandbox argument may be moot here…
Is loading environment variables from a file supported by Pants in this case?
To answer this, yes, if you use
scie-pants
(the new Pants launcher binary) you can have a
.env
file to load env vars from in the root of the repo. Otherwise you can have a
.pants.bootstrap
script with
export VAR=value
in it which will work in either launcher version (script or binary)
a

acoustic-garden-40182

05/10/2023, 4:45 PM
That's brilliant, thanks, I'll move the
.env
file.
👍 1
2 Views