dagger/dagger · error
failed to generate runtime dir: %w
Error message
failed to generate runtime dir: %w
What it means
After selecting the runtime in Codegen, the SDK delegates to NewBunRuntime/NewDenoRuntime/NewNodeRuntime.GenerateDir to produce the generated client directory. If any of those fail (dependency resolution, codegen binary execution, template generation, etc.), the error is wrapped as "failed to generate runtime dir". It means the per-runtime code generation step failed before the src/ template and entrypoint overlays.
Source
Thrown at sdk/typescript/runtime/main.go:100
cfg, err := analyzeModuleConfig(ctx, modSource)
if err != nil {
return nil, fmt.Errorf("failed to analyze module config: %w", err)
}
var codegen *dagger.Directory
switch cfg.runtime {
case Bun:
codegen, err = NewBunRuntime(cfg, t.SDKSourceDir, introspectionJSON).GenerateDir(ctx)
case Deno:
codegen, err = NewDenoRuntime(cfg, t.SDKSourceDir, introspectionJSON).GenerateDir(ctx)
case Node:
codegen, err = NewNodeRuntime(cfg, t.SDKSourceDir, introspectionJSON).GenerateDir(ctx)
default:
return nil, fmt.Errorf("unknown runtime %s", cfg.runtime)
}
if err != nil {
return nil, fmt.Errorf("failed to generate runtime dir: %w", err)
}
// TODO: handle that in an init method.
// Add default template if no source files exist
srcDirExist, err := cfg.source.Exists(ctx, SrcDir)
if err != nil {
return nil, fmt.Errorf("failed to check if src dir exists: %w", err)
}
sourceFiles := []string{}
if srcDirExist {
sourceFiles, err = cfg.source.Glob(ctx, "src/**/*.ts")
if err != nil {
return nil, fmt.Errorf("failed to list source files: %w", err)
}
}
if len(sourceFiles) == 0 {View on GitHub (pinned to 82ba2681db)
Solutions
- Read the wrapped inner error to identify the failing runtime-specific step.
- Re-run with `dagger --debug` for verbose engine logs.
- If using a custom SDK source (dagger.json sdk.source), verify that directory builds and is up to date.
- Update Dagger CLI and the module's SDK version to the latest and retry.
Defensive patterns
Strategy: retry
Validate before calling
// No pre-call validation can fully prevent this; ensure the SDK source dir exists before codegen:
if sdkSourceDir == nil { return errors.New("SDK source dir missing; do not pass a custom sdk.source unless it is complete") } Try / catch
codegen, err := runtime.GenerateDir(ctx)
if err != nil {
return nil, fmt.Errorf("failed to generate runtime dir: %w", err)
}
// On failure: re-run with dagger --debug and inspect the wrapped cause before retrying Prevention
- Retry transient engine failures once before investigating.
- Keep Dagger CLI and engine up to date.
- Verify custom SDK source directories (dagger.json sdk.source) build cleanly.
- Ensure network access for pulling runtime images (node/bun/deno).
When it happens
Trigger: Running `dagger develop` or `dagger functions` on a TypeScript module where the runtime-specific GenerateDir fails — e.g. the codegen binary crashes, introspectionJSON is unreadable, or the runtime setup (bun/deno/node container prep) errors for the given module config.
Common situations: Network/container failures while preparing the runtime image; an SDK source directory that is broken or missing (custom SDK via dagger.json `sdk: source`); engine-side errors during codegen execution.
Related errors
- unknown type %q
- enum types must be named
- failed to find decl for object %s: %w
- failed to find decl for named type %s: %w
- failed to find decl for method %s: %w
AI-assisted analysis of dagger/dagger@82ba2681db (2026-09-05).
Data as JSON: /api/errors/a5d1796e8f9951cf.
Report an issue: GitHub.