{"record":{"id":"a5d1796e8f9951cf","repo":"dagger/dagger","slug":"failed-to-generate-runtime-dir-w","errorCode":null,"errorMessage":"failed to generate runtime dir: %w","messagePattern":"failed to generate runtime dir: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"sdk/typescript/runtime/main.go","lineNumber":100,"sourceCode":"\tcfg, err := analyzeModuleConfig(ctx, modSource)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"failed to analyze module config: %w\", err)\n\t}\n\n\tvar codegen *dagger.Directory\n\tswitch cfg.runtime {\n\tcase Bun:\n\t\tcodegen, err = NewBunRuntime(cfg, t.SDKSourceDir, introspectionJSON).GenerateDir(ctx)\n\tcase Deno:\n\t\tcodegen, err = NewDenoRuntime(cfg, t.SDKSourceDir, introspectionJSON).GenerateDir(ctx)\n\tcase Node:\n\t\tcodegen, err = NewNodeRuntime(cfg, t.SDKSourceDir, introspectionJSON).GenerateDir(ctx)\n\tdefault:\n\t\treturn nil, fmt.Errorf(\"unknown runtime %s\", cfg.runtime)\n\t}\n\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"failed to generate runtime dir: %w\", err)\n\t}\n\n\t// TODO: handle that in an init method.\n\t// Add default template if no source files exist\n\tsrcDirExist, err := cfg.source.Exists(ctx, SrcDir)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"failed to check if src dir exists: %w\", err)\n\t}\n\n\tsourceFiles := []string{}\n\tif srcDirExist {\n\t\tsourceFiles, err = cfg.source.Glob(ctx, \"src/**/*.ts\")\n\t\tif err != nil {\n\t\t\treturn nil, fmt.Errorf(\"failed to list source files: %w\", err)\n\t\t}\n\t}\n\n\tif len(sourceFiles) == 0 {","sourceCodeStart":82,"sourceCodeEnd":118,"githubUrl":"https://github.com/dagger/dagger/blob/82ba2681dbe30d3547a1dc50ea495900ab5b6047/sdk/typescript/runtime/main.go#L82-L118","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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."],"exampleFix":null,"handlingStrategy":"retry","validationCode":"// No pre-call validation can fully prevent this; ensure the SDK source dir exists before codegen:\nif sdkSourceDir == nil { return errors.New(\"SDK source dir missing; do not pass a custom sdk.source unless it is complete\") }","typeGuard":null,"tryCatchPattern":"codegen, err := runtime.GenerateDir(ctx)\nif err != nil {\n    return nil, fmt.Errorf(\"failed to generate runtime dir: %w\", err)\n}\n// On failure: re-run with dagger --debug and inspect the wrapped cause before retrying","preventionTips":["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)."],"tags":["dagger","typescript-sdk","codegen","runtime"],"backgroundTag":"codegen-generation-failed","analyzedSha":"82ba2681dbe30d3547a1dc50ea495900ab5b6047","analyzedAt":"2026-09-05T07:21:37.930Z","contentChangedAt":"2026-09-05T07:21:37.930Z","schemaVersion":2},"datasetVersion":"2026-09-12T12:17:11.808Z"}