dagger/dagger · error

resolving toolchain module: %w

Error message

resolving toolchain module: %w

What it means

When resolving a module load whose source declares config toolchains (src.Self().ConfigToolchains), each toolchain module is resolved via resolveModuleSourceAsModule; failure is wrapped as 'resolving toolchain module'. It means one of the toolchain dependencies declared in the module configuration could not be built/loaded into a served Module.

Source

Thrown at engine/server/session_workspaces.go:1755

	}
	src := primary.Self().Source.Value
	defaultPathContextSrc := src
	if primary.Self().ContextSource.Valid && primary.Self().ContextSource.Value.Self() != nil {
		defaultPathContextSrc = primary.Self().ContextSource.Value
	}

	for i, toolchainSrc := range src.Self().Toolchains {
		if toolchainSrc.Self() == nil {
			continue
		}
		var cfg *modules.ModuleConfigDependency
		if i < len(src.Self().ConfigToolchains) {
			cfg = src.Self().ConfigToolchains[i]
		}
		pending := pendingRelatedModule(defaultPathContextSrc, toolchainSrc.Self(), cfg, false)
		toolchainMod, err := srv.resolveModuleSourceAsModule(ctx, dag, toolchainSrc, pending)
		if err != nil {
			return resolvedModuleLoad{}, fmt.Errorf("resolving toolchain module: %w", err)
		}
		resolved.related = append(resolved.related, resolvedServedModule{
			mod:        toolchainMod,
			entrypoint: false,
		})
	}

	if src.Self().Blueprint.Self() != nil {
		pending := pendingRelatedModule(defaultPathContextSrc, src.Self().Blueprint.Self(), src.Self().ConfigBlueprint, true)
		blueprintMod, err := srv.resolveModuleSourceAsModule(ctx, dag, src.Self().Blueprint, pending)
		if err != nil {
			return resolvedModuleLoad{}, fmt.Errorf("resolving blueprint module: %w", err)
		}
		resolved.related = append(resolved.related, resolvedServedModule{
			mod:        blueprintMod,
			entrypoint: true,
		})
		resolved.primaryEntrypoint = false

View on GitHub (pinned to 82ba2681db)

Solutions

  1. Read the inner (%w) error to find which toolchain module failed and why.
  2. Fix the toolchain module source: valid dagger.json, compilable code, correct path in config.
  3. Verify the toolchain's SDK matches what the engine supports and is installed.
  4. If toolchain comes from git, confirm the ref still exists and is reachable.

Example fix

// before (config)
[[toolchains]]
path = "./tools/old-toolchain" // moved away
// after
[[toolchains]]
path = "./tools/toolchain" // dir exists with valid dagger.json
Defensive patterns

Strategy: validation

Validate before calling

// preflight: toolchain dirs exist and are valid modules
for _, tc := range cfgToolchains { if _, err := os.Stat(filepath.Join(root, tc.Path, "dagger.json")); err != nil { return fmt.Errorf("toolchain %q missing dagger.json", tc.Path) } }

Try / catch

if err != nil { var mle resolvedModuleLoad; if errors.As(err, &mle) == false { /* inspect wrapped cause via %w chain */ } }

Prevention

When it happens

Trigger: A module's config declares ConfigToolchains entries whose source is broken: invalid module path in config, missing or errored toolchain module code (bad dagger.json, SDK init failure, compile error), or its git/local source unresolvable.

Common situations: Committed config pointing at a toolchain module directory that was moved/renamed; toolchain module's SDK not installed; syntax errors in the toolchain module source; pinning a git toolchain ref that no longer exists.

Related errors


AI-assisted analysis of dagger/dagger@82ba2681db (2026-09-05). Data as JSON: /api/errors/8afbbfd8cf080ff9. Report an issue: GitHub.