Skip to content

fix(polyfill): include local dir deps declared in dagger-module.toml#10

Draft
eunomie wants to merge 1 commit into
mainfrom
fix-generate-dir-module-dep
Draft

fix(polyfill): include local dir deps declared in dagger-module.toml#10
eunomie wants to merge 1 commit into
mainfrom
fix-generate-dir-module-dep

Conversation

@eunomie

@eunomie eunomie commented Jun 25, 2026

Copy link
Copy Markdown
Member

What

dagger generate on a workspace whose module declares a local directory dependency in dagger-module.toml fails:

export generated context before directory: failed to resolve dep to source:
dir module source does not contain a dagger config file

Repro: a workspace with the Go SDK and two modules where one depends on the other via a relative path (e.g. ../my-deps), then dagger generate.

Root cause

#7 added dagger-module.toml support to workspace-module-generate, but for TOML modules it returned an empty source config, on the assumption that the engine resolves includes and dependencies when the source is loaded:

if ok { // dagger-module.toml exists
    return sourceConfig{}, true, nil
}

That holds for a module's own files (loaded via "**"), but not for local directory dependencies: their directories live outside the module directory. moduleSourceInclude recurses over config.dependencies to pull each local dep's directory into the loaded context — with an empty config it never does, so the dependency's directory is dropped. The engine then loads the module as a dir source over that reduced context, resolves the dependency from its own dagger-module.toml, and fails because the dependency's directory isn't present.

Fix

Parse the dagger-module.toml dependencies (and include) so the recursion visits local dir dependencies and adds their directories to the loaded context.

  • TOML decoding is isolated in parseSourceConfigTOML, with a note pointing at feat: add asTOML and TOML value type dagger#13379: once File.asTOML ships and the helper's dagger.io/dagger is bumped, the local decode can be replaced by reading the fields through the engine API (dropping the pelletier/go-toml dependency).
  • Adds github.com/pelletier/go-toml v1.9.5 (same lib/version the engine uses).

Tests

  • TestParseSourceConfigTOMLReadsDependenciesAndInclude — TOML deps/include parse correctly.
  • TestModuleSourceIncludeReadsTOMLDependencies — a module whose dependency is declared only in dagger-module.toml now includes the dependency's directory.

go build, go vet, gofmt, go test all clean.

A polyfill-e2e end-to-end .generate check (with a dagger-module.toml fixture) is a sensible follow-up but needs a CLI-1.0 dev engine to validate; left out of this PR.

@eunomie eunomie closed this Jun 25, 2026
@eunomie eunomie force-pushed the fix-generate-dir-module-dep branch from c3dbd35 to 0ff9be8 Compare June 25, 2026 17:05
#7 added dagger-module.toml support to workspace-module-generate but, for
toml modules, returned an empty source config on the assumption that the
engine resolves includes and dependencies when the source is loaded. That
holds for a module's own files (loaded via "**"), but not for local
directory dependencies: their directories live outside the module and must
be added to the loaded context explicitly, or the engine fails with "dir
module source does not contain a dagger config file" during dagger generate.

Parse the dagger-module.toml dependencies (and include) so moduleSourceInclude
recurses into local dir dependencies and pulls their directories into the
loaded context.

Signed-off-by: Yves Brissaud <yves@dagger.io>
@eunomie eunomie reopened this Jun 25, 2026
@eunomie eunomie changed the title fix(polyfill): read dagger-module.toml deps when computing module include fix(polyfill): include local dir deps declared in dagger-module.toml Jun 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant