hashicorp/terraform · warning

Module initialization was canceled by an interrupt signal.

Error message

Module initialization was canceled by an interrupt signal.

What it means

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.

Source

Thrown at internal/command/meta_config.go:356

// 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),
	))
	defer span.End()

	loader, err := m.initConfigLoader()
	if err != nil {
		diags = diags.Append(err)
		return true, diags
	}

	targetDir = m.normalizePath(targetDir)
	moreDiags := initwd.DirFromModule(ctx, loader, targetDir, m.modulesDir(), addr, m.registryClient(), hooks)
	diags = diags.Append(moreDiags)
	if ctx.Err() == context.Canceled {
		m.showDiagnostics(diags)
		diags = diags.Append(fmt.Errorf("Module initialization was canceled by an interrupt signal."))
		return true, diags
	}
	return false, diags
}

// inputForSchema uses interactive prompts to try to populate any
// not-yet-populated required attributes in the given object value to
// comply with the given schema.
//
// An error will be returned if input is disabled for this meta or if
// values cannot be obtained for some other operational reason. Errors are
// not returned for invalid input since the input loop itself will report
// that interactively.
//
// It is not guaranteed that the result will be valid, since certain attribute
// types and nested blocks are not supported for input.
//
// The given value must conform to the given schema. If not, this method will

View on GitHub (pinned to c9def3e214)

Solutions

  1. Re-run `terraform init -from-module=<source>` to retry the copy.
  2. Verify network/Git access to the module source to avoid stalls.
  3. Use a stable, cached source or vendor the module.
  4. Let the copy complete rather than interrupting mid-fetch.

Example fix

// before
// terraform init -from-module=git::https://... -> Ctrl-C
// Module initialization was canceled by an interrupt signal.

// after
terraform init -from-module=git::https://...
Defensive patterns

Strategy: try-catch

Validate before calling

// Validate the -from-module source is reachable before a long copy
// (e.g. `git ls-remote` for git sources) to reduce chance of interrupt.

Try / catch

if err := runInitFromModule(ctx, src); err != nil {
    if errors.Is(err, context.Canceled) {
        return fmt.Errorf("from-module copy interrupted, re-run terraform init -from-module=%s", src)
    }
    return err
}

Prevention

When it happens

Trigger: 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>`.

Common situations: User aborts a slow `terraform init -from-module=git::...`; CI cancels a large module pull; network stall on the source fetch prompts an interrupt.

Related errors


AI-assisted analysis of hashicorp/terraform@c9def3e214 (2026-08-07). Data as JSON: /api/errors/7db85226696841e9. Report an issue: GitHub.