-
-
Notifications
You must be signed in to change notification settings - Fork 645
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
Precedence of environment variables not respected in v3.20.0 #993
Comments
Hi @blakewatters, I could not reproduce this issue. I tried with global # .env
FOO=foobar version: '3'
dotenv: ['.env']
tasks:
default:
env:
FOO: override
cmds:
- echo $FOO $ task
task: [default] echo $FOO
override version: '3'
tasks:
default:
dotenv: ['.env']
env:
FOO: override
cmds:
- echo $FOO $ task
task: [default] echo $FOO
override |
Okay let me try being a little more specific: I have a task that generates a
I have another task called What I am seeing that the values that wind up being written out to the file are the ones from the previously deleted In previous versions of Task, this all worked perfectly. Now I can only get the tasks to run by using an
Once the values from the previous |
I have a similar problem if a variable is already defined in the shell. For the taskfile: version: '3'
tasks:
default:
env:
FOO: override
cmds:
- echo $FOO everything works as expected: $ task
task: [default] echo $FOO
override But when I do the following: $ export FOO=foo
$ task
task: [default] echo $FOO
foo In my opinion it should print |
Indeed. The documentation explicitly informs that the expected behavior should be the opposite of what we get in the, as of now latest, v3.24.0 release and main branch. Like @zbindenren demonstrated in their comment, the observed output generated by the current implementation is that the predefined environment where Task is invoked is getting a greater precedence than any defined content of an I believe there's no "correct" way of defining this order, there are arguments and uses for both ways, but the documentation should reflect the actual behavior. What was the original intent? Should we fix the code or the docs? |
@bcdonadio That documentation for Task variables ( See discussion at #1038 (comment). Change that would be a breaking change, but maybe a setting would be nice to make all users happy (some people like the current behavior). |
@andreynering Yeah, I believe you're right. This line further reinforces the idea that they all follow the same rules, but doesn't specifically states that they behave the same in every possible case. I think it would be a good idea just to make this behavior clear in the docs of this major release (with a mere patch bump), and only after that discuss and ponder whether should that be implemented as a breaking change in the next major, if there should be a config statement to change the default behavior in the next minor or whatever the solution might ultimately be. Just trying to follow the principle of least surprise. |
I have the same problem... I want to override as a workaround, I am forced to override env var right before executing the Maven, for example:
setting env:
JAVA_HOME: '{{ .AEM_BUILD_JAVA_HOME }}' anywhere (global or task level) is not effective; maybe some new section like or sth like:
|
lol I find this entire discussion pretty amusing. We are 18 months deep and there is apparently some disagreement about whether or not a task such as:
Should just ignore the variable values explicitly provided via the vars stanza and defer to the environment? How is this even a discussion or a potentially breaking change? It is clearly incorrect. I am telling the task explicitly what I want the value to be and it is just ignoring it. It's a straight up bug and invalid behavior. Who in the universe is going to have their code broken by providing an explicit input value that is magically ignored based on the environment? |
Hi all, there are many open issues related to variables in v3. To help centralise and focus our discussions we have created a new megathread. The env precedence experiment is now stable and there are open tickets linked from the megathread to discuss inheritance and scoping so I'm going to close this issue. |
I suspect that this is related to the newly merge
task
leveldotenv
support.What I am seeing that environment variables specified explicitly at the
task
level no longer take precedence over ones defined bydotenv
. For example, given a Taskfile of the form:You will always get the value of
DATABASE_NAME
defined by dotenv rather than the override defined at the localtask
levelThe text was updated successfully, but these errors were encountered: