{"record":{"id":"7db85226696841e9","repo":"hashicorp/terraform","slug":"module-initialization-was-canceled-by-an-interrupt","errorCode":null,"errorMessage":"Module initialization was canceled by an interrupt signal.","messagePattern":"Module initialization was canceled by an interrupt signal\\.","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"internal/command/meta_config.go","lineNumber":356,"sourceCode":"// via a provided cli.Ui.\nfunc (m *Meta) initDirFromModule(ctx context.Context, targetDir string, addr string, hooks initwd.ModuleInstallHook) (abort bool, diags tfdiags.Diagnostics) {\n\tctx, span := tracer.Start(ctx, \"initialize directory from module\", trace.WithAttributes(\n\t\tattribute.String(\"source_addr\", addr),\n\t))\n\tdefer span.End()\n\n\tloader, err := m.initConfigLoader()\n\tif err != nil {\n\t\tdiags = diags.Append(err)\n\t\treturn true, diags\n\t}\n\n\ttargetDir = m.normalizePath(targetDir)\n\tmoreDiags := initwd.DirFromModule(ctx, loader, targetDir, m.modulesDir(), addr, m.registryClient(), hooks)\n\tdiags = diags.Append(moreDiags)\n\tif ctx.Err() == context.Canceled {\n\t\tm.showDiagnostics(diags)\n\t\tdiags = diags.Append(fmt.Errorf(\"Module initialization was canceled by an interrupt signal.\"))\n\t\treturn true, diags\n\t}\n\treturn false, diags\n}\n\n// inputForSchema uses interactive prompts to try to populate any\n// not-yet-populated required attributes in the given object value to\n// comply with the given schema.\n//\n// An error will be returned if input is disabled for this meta or if\n// values cannot be obtained for some other operational reason. Errors are\n// not returned for invalid input since the input loop itself will report\n// that interactively.\n//\n// It is not guaranteed that the result will be valid, since certain attribute\n// types and nested blocks are not supported for input.\n//\n// The given value must conform to the given schema. If not, this method will","sourceCodeStart":338,"sourceCodeEnd":374,"githubUrl":"https://github.com/hashicorp/terraform/blob/c9def3e214014c1188faabfc4a5bde5095139765/internal/command/meta_config.go#L338-L374","documentation":"Raised during directory-from-module initialization (initDirFromModule, used by `terraform init -from-module`) when the context was canceled by an interrupt signal. Similar to module-install cancellation but for the top-level 'init this dir from a module source' flow.","triggerScenarios":"initDirFromModule: after initwd.DirFromModule returns, ctx.Err()==context.Canceled. Triggered by Ctrl-C or external cancellation while copying the module source into the target directory during `terraform init -from-module=<source>`.","commonSituations":"User aborts a slow `terraform init -from-module=git::...`; CI cancels a large module pull; network stall on the source fetch prompts an interrupt.","solutions":["Re-run `terraform init -from-module=<source>` to retry the copy.","Verify network/Git access to the module source to avoid stalls.","Use a stable, cached source or vendor the module.","Let the copy complete rather than interrupting mid-fetch."],"exampleFix":"// before\n// terraform init -from-module=git::https://... -> Ctrl-C\n// Module initialization was canceled by an interrupt signal.\n\n// after\nterraform init -from-module=git::https://...","handlingStrategy":"try-catch","validationCode":"// Validate the -from-module source is reachable before a long copy\n// (e.g. `git ls-remote` for git sources) to reduce chance of interrupt.","typeGuard":null,"tryCatchPattern":"if err := runInitFromModule(ctx, src); err != nil {\n    if errors.Is(err, context.Canceled) {\n        return fmt.Errorf(\"from-module copy interrupted, re-run terraform init -from-module=%s\", src)\n    }\n    return err\n}","preventionTips":["Let the -from-module copy finish rather than interrupting.","Verify network/Git access to the source beforehand.","Use a cached or vendored source when possible.","Re-run init -from-module after an interrupt; the copy is retried."],"tags":["terraform","init","from-module","interrupt","cancellation"],"analyzedSha":"c9def3e214014c1188faabfc4a5bde5095139765","analyzedAt":"2026-08-07T15:39:49.278Z","schemaVersion":2},"datasetVersion":"2026-08-07T21:17:07.882Z"}