-
Notifications
You must be signed in to change notification settings - Fork 4.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
--action_env with defined value is not working as expected #8578
Comments
If you want to set an environment variable for the tool you want to run with "bazel run", then you can just set that environment variable before calling Bazel, like so:
The --action_env command line flag is intended to pass environment variables to build actions (--test_env to pass to test actions). We don't consider the binary-to-run as a build action. Only exception: if you bazel run a test target, it'll also add the environment variables from --action_env and --test_env. |
@ulfjack I think its a bit limited not having a way to predefined the environment variables via Bazel. One simple use case is I really dont want to build a Makefile to invoke my |
Note this also affects the ability to set env vars to targets on run configurations on JetBrains based IDEs as you can't set env vars on the run config. So you loose the ability to debug targets that require ENV vars |
Another example of this limitation: OpenAPI generator, that generates source code from API definition (swagger) files. If you want the generated source files to be go-formatted, you must set the environment variable I tried
None of them works... From the OpenAPI generator output: |
Why was this closed? I don't see any particular fix? Also is there really no possibility to set an environment variable for the e.g. in my case I building docker images via |
Why is this closed? I'm running bazel in a container and neither the |
+1 |
Yes this issue still is there in various variations, see also #17062 |
I assume that the reason this is closed is that it is too broad. I parsed at least the following topics out of this thread that probably deserve new, more focused issues if anybody is interested in seeing them resolved:
|
Part of the confusion seems to be the naming: Especially with only the output of |
+1 to this issue. Not being able to pass in environment variables to the target binary through Update: My team primarily uses bazel for Java. We used |
Description of the problem:
According to the docs,
--action_env
could be used to set name=value pairs:If such values are set either via CLI arguments or via
.bazelrc
like this:then only
--test_env
works as expected and passes env correctly.--action_env
does not pass value to the binary target (checked with Go and JS toolchains, issue is not related to lang rules).Bugs: what's the simplest, easiest way to reproduce this bug? Please provide a minimal example if possible.
Use this repo to reproduce:
https://github.com/siberex/bazel_--action_env
--test_env
is working:Note:
Without predefined value it works fine taking env value from invocation environment:
HELLO=WORLD bazel run //:js --action_env=HELLO
. Issue is related only toname=value
syntax.What operating system are you running Bazel on?
Mac OS 10.14.5
What's the output of
bazel info release
?release 0.26.1
Have you found anything relevant by searching the web?
Could not find anything relevant.
The text was updated successfully, but these errors were encountered: