Skip to content

Task attribute clear = true incorrectly clears properties inherited via extend #1326

@nan-mu

Description

@nan-mu

Describe The Bug

I wrote a subcommand setup for build following the instructions in the README. When running it, I noticed that the clear attribute overrides extend. I believe this is unexpected behavior; clear should be evaluated before extend.

To Reproduce

  1. Add the following to a Makefile.toml:
    [tasks.build]
    clear = true
    private = false
    extend = "subcommand"
    env = { "SUBCOMMAND_PREFIX" = "build" }
    
    [tasks.subcommand]
    private = true
    script = '''
    #!@duckscript
    
    cm_run_task ${SUBCOMMAND_PREFIX}_${1}
    '''
  2. Run any subcommand. You will find that the subcommand does not take effect, and tasks.subcommand is not executed.

Error Stack

by cargo make --print-steps build firmware

[cargo-make] INFO - cargo make 0.37.24
[cargo-make] INFO - 
[cargo-make] INFO - Build File: Makefile.toml
[cargo-make] INFO - Task: build
[cargo-make] INFO - Profile: development
ExecutionPlan {
    steps: [
        Step {
            name: "init",
            config: Task {
                clear: None,
                description: Some(
                    "By default this task is invoked at the start of every cargo-make run.",
                ),
                category: Some(
                    "Hooks",
                ),
                disabled: None,
                private: None,
                deprecated: None,
                extend: None,
                workspace: None,
                plugin: None,
                watch: None,
                condition: None,
                condition_script: None,
                condition_script_runner_args: None,
                ignore_errors: None,
                force: None,
                env_files: None,
                env: None,
                cwd: None,
                alias: None,
                linux_alias: None,
                windows_alias: None,
                mac_alias: None,
                install_crate: None,
                install_crate_args: None,
                install_script: None,
                command: None,
                args: None,
                script: None,
                script_runner: None,
                script_runner_args: None,
                script_extension: None,
                run_task: None,
                dependencies: None,
                toolchain: None,
                linux: None,
                windows: None,
                mac: None,
            },
        },
        Step {
            name: "build",
            config: Task {
                clear: Some(
                    true,
                ),
                description: None,
                category: None,
                disabled: None,
                private: Some(
                    false,
                ),
                deprecated: None,
                extend: Some(
                    "subcommand",
                ),
                workspace: None,
                plugin: None,
                watch: None,
                condition: None,
                condition_script: None,
                condition_script_runner_args: None,
                ignore_errors: None,
                force: None,
                env_files: None,
                env: Some(
                    {
                        "SUBCOMMAND_PREFIX": Value(
                            "build",
                        ),
                        "CARGO_MAKE_CURRENT_TASK_INITIAL_MAKEFILE": Value(
                            "/Users/name/bs/Makefile.toml",
                        ),
                        "CARGO_MAKE_CURRENT_TASK_INITIAL_MAKEFILE_DIRECTORY": Value(
                            "/Users/name/bs",
                        ),
                    },
                ),
                cwd: None,
                alias: None,
                linux_alias: None,
                windows_alias: None,
                mac_alias: None,
                install_crate: None,
                install_crate_args: None,
                install_script: None,
                command: None,
                args: None,
                script: None,
                script_runner: None,
                script_runner_args: None,
                script_extension: None,
                run_task: None,
                dependencies: None,
                toolchain: None,
                linux: None,
                windows: None,
                mac: None,
            },
        },
        Step {
            name: "end",
            config: Task {
                clear: None,
                description: Some(
                    "By default this task is invoked at the end of every cargo-make run.",
                ),
                category: Some(
                    "Hooks",
                ),
                disabled: None,
                private: None,
                deprecated: None,
                extend: None,
                workspace: None,
                plugin: None,
                watch: None,
                condition: None,
                condition_script: None,
                condition_script_runner_args: None,
                ignore_errors: None,
                force: None,
                env_files: None,
                env: None,
                cwd: None,
                alias: None,
                linux_alias: None,
                windows_alias: None,
                mac_alias: None,
                install_crate: None,
                install_crate_args: None,
                install_script: None,
                command: None,
                args: None,
                script: None,
                script_runner: None,
                script_runner_args: None,
                script_extension: None,
                run_task: None,
                dependencies: None,
                toolchain: None,
                linux: None,
                windows: None,
                mac: None,
            },
        },
    ],
}

Code Sample

[tasks.build]
clear = true
private = false
extend = "subcommand"
env = { "SUBCOMMAND_PREFIX" = "build" }

[tasks.subcommand]
private = true
script = '''
#!@duckscript

cm_run_task ${SUBCOMMAND_PREFIX}_${1}
'''

I searched the existing issues using "extend" and "clear" as keywords to see if anyone had reported this, and it appears no one has. If this has already been addressed in another issue, I apologize for the duplicate.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions