dagger/dagger · error
failed to update tsconfig.json: %w
Error message
failed to update tsconfig.json: %w
What it means
This error is returned by CreateOrUpdateTSConfigForModule when tsutils.UpdateTSConfigForModule cannot merge Dagger's required compilerOptions/paths into the module's existing tsconfig.json. It wraps the underlying cause (almost always invalid JSON in tsconfig.json) so the engine's output names the failing step. It only fires when a tsconfig.json already exists in the module source; a missing file would trigger the default-config path instead.
Source
Thrown at sdk/typescript/runtime/config_updator.go:34
if err != nil {
return nil, fmt.Errorf("failed to lookup for tsconfig.json: %w", err)
}
// If no tsconfig.json is found in the user module, we generate a default one.
if !tsconfigExist {
defaultTSConfigContent := tsutils.DefaultTSConfig()
return dag.File("tsconfig.json", defaultTSConfigContent).Sync(ctx)
}
tsConfigContent, err := modSourceDir.File("tsconfig.json").Contents(ctx)
if err != nil {
return nil, fmt.Errorf("failed to read module's tsconfig.json: %w", err)
}
updatedTSConfigContent, err := tsutils.UpdateTSConfigForModule(tsConfigContent)
if err != nil {
return nil, fmt.Errorf("failed to update tsconfig.json: %w", err)
}
return dag.File("tsconfig.json", updatedTSConfigContent).Sync(ctx)
}
func CreateOrUpdateTSConfigForClient(ctx context.Context, modSourceDir *dagger.Directory, isRemote bool) (*dagger.File, error) {
tsConfigExist, err := modSourceDir.Exists(ctx, "tsconfig.json")
if err != nil {
return nil, fmt.Errorf("failed to lookup for tsconfig.json: %w", err)
}
if !tsConfigExist {
defaultTSConfigContent := tsutils.DefaultTSConfig()
return dag.File("tsconfig.json", defaultTSConfigContent).Sync(ctx)
}
tsConfigContent, err := modSourceDir.File("tsconfig.json").Contents(ctx)
if err != nil {View on GitHub (pinned to 82ba2681db)
Solutions
- Validate your tsconfig.json with a strict JSON parser (e.g. `jq . tsconfig.json`) and fix any syntax errors such as trailing commas or comments.
- If the file uses jsonc-style comments, move them out or re-encode the file as plain UTF-8 (no BOM) JSON.
- Temporarily delete tsconfig.json and re-run so Dagger generates a known-good default, then re-apply your custom settings on top.
- Inspect the wrapped `%w` cause in the full error chain to identify the exact parse failure and file region.
Example fix
// before (tsconfig.json with trailing comma)
{
"compilerOptions": {
"strict": true,
}
}
// after
{
"compilerOptions": {
"strict": true
}
} Defensive patterns
Strategy: validation
Validate before calling
// run before dagger develop jq empty tsconfig.json && echo ok || echo 'tsconfig.json is not valid strict JSON'
Try / catch
// bash wrapper if ! dagger develop; then jq empty tsconfig.json || (rm tsconfig.json && dagger develop) # regenerate default fi
Prevention
- Keep tsconfig.json as strict JSON: no comments, no trailing commas, no BOM.
- Validate tsconfig.json in pre-commit hooks with jq or a JSON linter.
- Let Dagger generate the default tsconfig and apply custom settings on top.
When it happens
Trigger: Running `dagger develop`/`dagger call` on a TypeScript module whose committed tsconfig.json exists but fails UpdateTSConfigForModule — typically because the file contains invalid JSON (comments, trailing commas, BOM) or is malformed such that the updater cannot parse/merge it.
Common situations: A developer hand-edited tsconfig.json and left a trailing comma or comment (jsonc content in a file parsed as strict JSON); the file was truncated by a bad merge; an encoding issue (UTF-16/BOM) from a Windows editor; or an old tsconfig format that the updater no longer understands.
Related errors
- unknown runtime: %s
- unknown runtime: %q
- failed to lookup for tsconfig.json: %w
- failed to read module's tsconfig.json: %w
- failed to update deno config paths: %w
AI-assisted analysis of dagger/dagger@82ba2681db (2026-09-05).
Data as JSON: /api/errors/38e6adc394c6ee2b.
Report an issue: GitHub.