hashicorp/terraform · warning
Module installation was canceled by an interrupt signal.
Error message
Module installation was canceled by an interrupt signal.
What it means
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.
Source
Thrown at internal/command/meta_config.go:323
Parallelism: 1,
})
diags = diags.Append(ctxDiags)
if diags.HasErrors() {
return nil, diags
}
return ctx.Init(rootMod, terraform.InitOpts{
Walker: walker,
SetVariables: variables,
})
}
inst := initwd.NewModuleInstaller(m.modulesDir(), loader, m.registryClient(), initializer)
_, moreDiags := inst.InstallModules(ctx, rootDir, testsDir, upgrade, installErrsOnly, hooks...)
diags = diags.Append(moreDiags)
if ctx.Err() == context.Canceled {
m.showDiagnostics(diags)
diags = diags.Append(fmt.Errorf("Module installation was canceled by an interrupt signal."))
return true, diags
}
return false, diags
}
// initDirFromModule initializes the given directory (which should be
// pre-verified as empty by the caller) by copying the source code from the
// given module address.
//
// Internally this runs similar steps to installModules.
// The given hooks object will be notified of installation progress, which
// can then be relayed to the end-user. The uiModuleInstallHooks type in
// this package has a reasonable implementation for displaying notifications
// via a provided cli.Ui.
func (m *Meta) initDirFromModule(ctx context.Context, targetDir string, addr string, hooks initwd.ModuleInstallHook) (abort bool, diags tfdiags.Diagnostics) {
ctx, span := tracer.Start(ctx, "initialize directory from module", trace.WithAttributes(
attribute.String("source_addr", addr),View on GitHub (pinned to c9def3e214)
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.
Example fix
// before // terraform init -> user presses Ctrl-C // Module installation was canceled by an interrupt signal. // after terraform init // resumes; cached modules speed re-run
Defensive patterns
Strategy: try-catch
Validate before calling
// Check context before running, and handle cancellation gracefully ctx, cancel := context.WithCancel(context.Background()) defer cancel() // run init in a way that tolerates cancellation; let it complete or time out
Try / catch
// Wrap init invocation; on interrupt, advise re-run
if err := runInit(ctx); err != nil {
if errors.Is(err, context.Canceled) {
// non-fatal: modules are partially cached
return fmt.Errorf("init interrupted, please re-run terraform init")
}
return err
} Prevention
- 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.
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- Module initialization was canceled by an interrupt signal.
- failed to create local modules directory: %s
- root module not found. Please run terraform init
- execution halted
- canceled reading current outputs
AI-assisted analysis of hashicorp/terraform@c9def3e214 (2026-08-07).
Data as JSON: /api/errors/a1821dc26b9f74dc.
Report an issue: GitHub.