Skip to content

Tasks fail on unmet preconditions even when up-to-date #2691

@benblank

Description

@benblank

Description

When running the provided example taskfile, it fails with the messages:

task: `false` failed
task: Failed to run task "default": task: Failed to run task "some-task": task: precondition not met

However, if the preconditions for "some-task" are removed, it instead succeeds with:

task: Task "some-task" is up to date
task: [default] echo 'Running default!'
Running default!

In neither case are the commands for "some-task" actually run. Based on the documentation, I understand preconditions to mean something like "can this task run?" and status to mean something like "should this task run?" So it seems that Task is insisting that it be possible to run the task even when it knows it doesn't need to, which I find surprising. (And unhelpful. 😅)

My use case is that I'm trying to use Task to provision new hosts. One early task is "mkfs", which formats the partition; it has preconditions that ensure the partition is not currently mounted (which would prevent formatting) and a status which checks that the partition is already correctly formatted. The next task mounts the new filesystem. The problem is that later tasks need the filesystem to be mounted, but they ultimately depend on "mkfs", which fails because it's preconditions aren't met even though that task is up-to-date and doesn't need to run again.

Version

3.48.0+09e7247d (via Arch Linux package extra/go-task 3.48.0-1)

Operating system

Linux

Experiments Enabled

No response

Example Taskfile

version: "3"

tasks:
  some-task:
    preconditions: ["false"]
    cmd: "echo 'Running some-task!'"
    status: ["true"]
    run: once

  default:
    deps: ["some-task"]
    cmd: "echo 'Running default!'"

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions