Skip to content

misleading feature: "generates" and checksum checker #2181

Description

@viktorasm

Description

It's very misleading how task.generates feature works.

One would assume that the task will run if combined checksum of sources and outputs does not match sources/results of previous execution, e.g. having such definition

sources:
   - openapi.yaml
generates:
   - client/go/**/*.go

.. One would expect that if some generated files are missing, or are unintentionally changed, this will cause task to rerun.

How it actually works with checksum checker:

  • Checksum is calculated and checked for sources;
  • For generates list, it's only verified that glob matches any files.

This means that "generates" is only somewhat usable with absolute file names, as that would ensure the files existence at the very least. With globing, if some of the files are deleted, that's never detected.

The current checksum implementation handling of the "generates" :

	if len(t.Generates) > 0 {
		// For each specified 'generates' field, check whether the files actually exist
		for _, g := range t.Generates {
			if g.Negate {
				continue
			}
			generates, err := glob(t.Dir, g.Glob)
			if os.IsNotExist(err) {
				return false, nil
			}
			if err != nil {
				return false, err
			}
			if len(generates) == 0 {
				return false, nil
			}
		}
	}

we can see that the Task will be considered out of date with respect to "generates" only if glob value is invalid or it is returning no files.

Probably the best fix would be to actually include generated files into checksum calculation.

Version

main branch

Operating system

all

Experiments Enabled

No response

Example Taskfile

Activity

  1. added
    area: fingerprintingChanges related to checksums and caching.
    and removed
    state: needs triageWaiting to be triaged by a maintainer.
    on Apr 15, 2025
  2. ameershira commented on Apr 22, 2025

    @ameershira

    This is really one of those features that is REALLY required. For us to live up to the "simpler than Make" statement. The basic feature of only executing when required needs to be supported.

    My previous issue: #1741

    My last statement: #1741 (comment)

    Other related issues: #1945

    Related PR: #1816

  3. hanoii commented on Jun 8, 2026

    @hanoii

    Also I think is useful if one can simple tell generates about a directory, i.e:

    tasks:
      build:
        dir: web/theme
        cmds:
          - n auto
          - npm i -g yarn
          - yarn install
          - npx mix --production
        sources:
          - '*.lock'
        generates:
          - dist # or - dist/
    
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area: fingerprintingChanges related to checksums and caching.

    Fields

    No fields configured for feature.

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions