dagger/dagger · error

module %q: %w

Error message

module %q: %w

What it means

This error wraps any failure that occurs while resolving the module source of an overlay module entry in the workspace config (dagger.json [modules] table). The resolver workspaceOverlayModuleSource may fail because the source path or remote ref cannot be resolved against the overlay rootfs or config. Dagger re-throws it prefixed with `module "<name>":` so you know which config entry is broken.

Source

Thrown at core/schema/workspace_overlay_modules.go:120

	for _, name := range names {
		if wanted != nil {
			if _, ok := wanted[canonicalOverlayModuleName(name)]; !ok {
				continue
			}
		}
		entry := cfg.Modules[name]
		// A built-in SDK install entry carries [as-sdk] authoring metadata, not
		// a loadable module ref (see workspaceConfigPendingModules).
		if entry.AsSDK != nil && coresdk.IsBuiltinSDKName(entry.Source) {
			continue
		}
		if entry.LegacyDefaultPath {
			continue
		}

		src, relevant, err := s.workspaceOverlayModuleSource(ctx, srv, parent, entry, configDir, configTouched)
		if err != nil {
			return nil, fmt.Errorf("module %q: %w", name, err)
		}
		if !relevant {
			continue
		}

		asModuleArgs, err := BuildLegacyAsModuleArgs(
			name,
			false, // legacy +defaultPath entries are skipped above
			"", "",
			entry.Settings,
			cfg.DefaultsFromDotEnv,
			nil,
		)
		if err != nil {
			return nil, fmt.Errorf("module %q: %w", name, err)
		}

		var mod dagql.ObjectResult[*core.Module]

View on GitHub (pinned to 82ba2681db)

Solutions

  1. Check the `source` value of the failing module in dagger.json and fix the path or ref
  2. Run `dagger develop` / re-install the module (`dagger install <name>`) to refresh the config entry
  3. If the module was intentionally removed, delete its entry from the [modules] table
  4. For remote refs, verify credentials and network access to the source repository

Example fix

// before (dagger.json)
"modules": { "mylib": { "source": "../libs/mylib" } }
// after
"modules": { "mylib": { "source": "./libs/mylib" } }
Defensive patterns

Strategy: validation

Validate before calling

// Go: before loading, verify each [modules] entry source exists / is fetchable
for name, entry := range cfg.Modules {
    if workspace.IsLocalRef(entry.Source, "") {
        if _, err := os.Stat(filepath.Join(configDir, entry.Source)); err != nil {
            return fmt.Errorf("module %q source %q missing: %w", name, entry.Source, err)
        }
    }
}

Try / catch

// Go
deps, err := ws.Modules(ctx)
if err != nil {
    var modErr *fmt.WrapError // or strings.Contains check
    if strings.Contains(err.Error(), "module ") {
        log.Fatalf("bad workspace module entry: %v — fix dagger.json [modules]", err)
    }
    return err
}

Prevention

When it happens

Trigger: Calling workspaceTargetModules when a workspace config entry's source cannot be resolved: a local path in dagger.json [modules] does not exist, a remote ref (git) cannot be fetched, or the config entry's settings/resolve fails during ApplyEnvOverlay-driven loading.

Common situations: Typoed or deleted module directory referenced in dagger.json; renamed module dir without updating config; remote module ref pointing at a private repo without credentials; stale config after pulling a branch where the module moved.

Related errors


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