Hi everyone. I've tried searching this channel to ...
# general
a
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
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
That's brilliant, thanks, I'll move the
.env
file.
👍 1