dagger/dagger · error
load workspace arg %q: %w
Error message
load workspace arg %q: %w
What it means
DynamicInputsForCall automatically injects the current workspace (module directory) into arguments typed for it when not supplied. If fn.loadWorkspaceArg fails, the error is wrapped as "load workspace arg %q" naming the argument that would have received the workspace.
Source
Thrown at core/modfunc.go:740
return nil
}
ctxArgVals[i] = &argInput{
argName: arg.Name,
val: ctxVal,
}
return nil
})
}
// Process workspace arguments - automatically inject workspace when not set
workspaceArgVals := make([]*argInput, len(workspaceArgs))
for i, arg := range workspaceArgs {
eg.Go(func() error {
wsVal, err := fn.loadWorkspaceArg(ctx, srv)
if err != nil {
return fmt.Errorf("load workspace arg %q: %w", arg.Name, err)
}
workspaceArgVals[i] = &argInput{
argName: arg.Name,
val: wsVal,
}
return nil
})
}
// Process user-defined user defaults for objects (and lists of objects)
type userDefaultArgInput struct {
argName string
val dagql.Input
}
userDefaultVals := make([]*userDefaultArgInput, len(userDefaults))
for i, userDefault := range userDefaults {View on GitHub (pinned to 82ba2681db)
Solutions
- Run the command from within a valid dagger module directory (where dagger.json exists).
- Pass the directory argument explicitly instead of relying on workspace injection.
- Verify the module source directory loads correctly (git status, file permissions).
- Check the wrapped inner error for the underlying workspace load failure.
Example fix
# before (run outside module) cd /somewhere && dagger call build # after cd /path/to/my-module && dagger call build
Defensive patterns
Strategy: validation
Validate before calling
# Ensure the command runs inside a valid dagger module (dagger.json present) if [ ! -f dagger.json ]; then echo "not in a dagger module"; exit 1; fi
Try / catch
_, err := fn.Call(ctx, args)
if err != nil && strings.Contains(err.Error(), "load workspace arg") {
// supply the workspace directory explicitly
args["workspace"] = dag.Host().Directory(".")
_, err = fn.Call(ctx, args)
} Prevention
- Always run dagger call from a directory containing dagger.json.
- Pass workspace-typed arguments explicitly in scripts that may run outside the module root.
- Verify git worktrees/checkouts in CI include the module source.
- Check the inner error for the actual workspace load failure.
When it happens
Trigger: Calling a function with a parameter qualifying for automatic workspace injection, while resolving the workspace itself fails — e.g. the module has no valid source directory in this context.
Common situations: Running dagger call outside a valid module context; the module source directory failed to load; git worktree/checkout issues in CI making the workspace unresolvable.
Related errors
- %s.%s(%s=): load user default: %w
- load contextual arg %q: %w
- set call inputs: %w
- load current workspace: %w
- get current workspace ID: %w
AI-assisted analysis of dagger/dagger@82ba2681db (2026-09-05).
Data as JSON: /api/errors/187759d5ef5fdd8a.
Report an issue: GitHub.