{"record":{"id":"a1821dc26b9f74dc","repo":"hashicorp/terraform","slug":"module-installation-was-canceled-by-an-interrupt-s","errorCode":null,"errorMessage":"Module installation was canceled by an interrupt signal.","messagePattern":"Module installation was canceled by an interrupt signal\\.","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"internal/command/meta_config.go","lineNumber":323,"sourceCode":"\t\t\tParallelism: 1,\n\t\t})\n\t\tdiags = diags.Append(ctxDiags)\n\t\tif diags.HasErrors() {\n\t\t\treturn nil, diags\n\t\t}\n\t\treturn ctx.Init(rootMod, terraform.InitOpts{\n\t\t\tWalker:       walker,\n\t\t\tSetVariables: variables,\n\t\t})\n\t}\n\tinst := initwd.NewModuleInstaller(m.modulesDir(), loader, m.registryClient(), initializer)\n\n\t_, moreDiags := inst.InstallModules(ctx, rootDir, testsDir, upgrade, installErrsOnly, hooks...)\n\tdiags = diags.Append(moreDiags)\n\n\tif ctx.Err() == context.Canceled {\n\t\tm.showDiagnostics(diags)\n\t\tdiags = diags.Append(fmt.Errorf(\"Module installation was canceled by an interrupt signal.\"))\n\t\treturn true, diags\n\t}\n\n\treturn false, diags\n}\n\n// initDirFromModule initializes the given directory (which should be\n// pre-verified as empty by the caller) by copying the source code from the\n// given module address.\n//\n// Internally this runs similar steps to installModules.\n// The given hooks object will be notified of installation progress, which\n// can then be relayed to the end-user. The uiModuleInstallHooks type in\n// this package has a reasonable implementation for displaying notifications\n// 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),","sourceCodeStart":305,"sourceCodeEnd":341,"githubUrl":"https://github.com/hashicorp/terraform/blob/c9def3e214014c1188faabfc4a5bde5095139765/internal/command/meta_config.go#L305-L341","documentation":"Raised during module installation when the context was canceled (ctx.Err() == context.Canceled), i.e. the user sent an interrupt signal (Ctrl-C) or the calling context was canceled. It is a clean, intentional abort; partial downloads may remain and init is marked aborted.","triggerScenarios":"installModules: after inst.InstallModules returns, ctx.Err()==context.Canceled. Triggered by the user pressing Ctrl-C during `terraform init`, or a parent process (wrapper/CI) canceling the run while modules are downloading.","commonSituations":"User hits Ctrl-C because a module download is slow/hung; CI job times out and cancels; orchestration cancels init to switch strategy; flaky registry causing a long stall the user aborts.","solutions":["Re-run `terraform init`; module downloads are cached and will resume from partial progress.","Check connectivity to the module registry/Git source if downloads stall repeatedly.","Pre-download modules on a stable network or vendor them (//modules:... with vendoring).","Avoid interrupting mid-download unless necessary; let init complete or time out cleanly."],"exampleFix":"// before\n// terraform init  -> user presses Ctrl-C\n// Module installation was canceled by an interrupt signal.\n\n// after\nterraform init   // resumes; cached modules speed re-run","handlingStrategy":"try-catch","validationCode":"// Check context before running, and handle cancellation gracefully\nctx, cancel := context.WithCancel(context.Background())\ndefer cancel()\n// run init in a way that tolerates cancellation; let it complete or time out","typeGuard":null,"tryCatchPattern":"// Wrap init invocation; on interrupt, advise re-run\nif err := runInit(ctx); err != nil {\n    if errors.Is(err, context.Canceled) {\n        // non-fatal: modules are partially cached\n        return fmt.Errorf(\"init interrupted, please re-run terraform init\")\n    }\n    return err\n}","preventionTips":["Let `terraform init` complete rather than interrupting mid-download.","Run init on a stable network to avoid stalls that tempt Ctrl-C.","Vendor modules or use a plugin/module cache to reduce download time.","Treat interrupt-during-init as recoverable: re-run init."],"tags":["terraform","init","modules","interrupt","cancellation"],"analyzedSha":"c9def3e214014c1188faabfc4a5bde5095139765","analyzedAt":"2026-08-07T15:39:49.278Z","schemaVersion":2},"datasetVersion":"2026-08-07T21:17:07.882Z"}