sagiegurari / cargo-make

Rust task runner and build tool.
https://sagiegurari.github.io/cargo-make/
Apache License 2.0
2.59k stars 125 forks source link

Overriding part of a task definition causes the original task's `env` to be lost during merge #1111

Open wmmc88 opened 4 months ago

wmmc88 commented 4 months ago

Describe The Bug

If a define a task in a makefile with an env scoped to the task, and then extend that task in another makefile, the env block gets lost.

To Reproduce

Makefile.toml:

extend = "./other.toml"

[tasks.my-task]

other.toml:

[tasks.my-task]
env = { A = "1", B = "2", C = "3" }
script = '''
#!@duckscript
echo A=${A} B=${B} C=${C}
'''

Error Stack

cargo make my-task
[cargo-make] INFO - cargo make 0.37.13
[cargo-make] INFO - Build File: Makefile.toml
[cargo-make] INFO - Task: my-task
[cargo-make] INFO - Profile: development
[cargo-make] INFO - Running Task: my-task
A= B= C=
[cargo-make] INFO - Build Done in 1.50 seconds.

When I comment out the "overidden" task definition in Makefile.toml, the output is correct:

cargo make my-task
[cargo-make] INFO - cargo make 0.37.13
[cargo-make] INFO - Build File: Makefile.toml
[cargo-make] INFO - Task: my-task
[cargo-make] INFO - Profile: development
[cargo-make] INFO - Running Task: my-task
A=1 B=2 C=3
[cargo-make] INFO - Build Done in 1.54 seconds.
sagiegurari commented 3 months ago

@wmmc88 i suspect it might be related to the fact i 'push' env vars to tasks like what makefile created them and their task name in the descriptor/mod.rs (if i remember correctly). would you like to PR this?