Skip to content

Make dagger.json include/exclude patterns consistent with defaultPath #8547

Closed

Description

@helderco

Summary

Make include/exclude patterns dagger.json relative to the context directory if they start with a slash (/).

Motivation

The include and exclude patterns in a dagger.json are always relative to the dagger.json file.

But with the recent Context directory feature, module authors are able to specify a path that is either relative to the root directory, or absolute to the context directory.

Example for a foo/bar module:

Feature <repo root>/src <module root>/src
dagger.json include/exclude ../../src src
defaultPath ../../src or /src src

Sometimes a /src is easier to manage than ../../src (less brittle to move directory and even to read depending on how deep in the file tree a module is), and it’s more consistent with how defaultPath resolves in relation to the context directory. There was a need for this there, and I think the same need applies here.

Compatibility

The downside is that it’s possibly a breaking change for anyone that already has include/exclude patterns in their dagger.json that start with a slash (/).

One way to mitigate this is to emit a warning until next minor version bump if we detect patterns that start with a slash, to let users know the meaning of that will change in a future version. Solution for them is to remove that slash prefix. Then make this change in that version.

No strong conviction to go down this road, just leaving it here and see if there’s demand.

Activity

  1. locked and limited conversation to collaborators on Mar 24, 2026
  2. converted this issue into a discussion #12157 on Mar 24, 2026
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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions