hashicorp/terraform · error

Error checking configuration

Error message

Error checking configuration: %s

What it means

Thrown after module copy when configs.IsEmptyDir(path, TestsDirectory) errors while checking whether the working directory contains configuration. This check decides whether to proceed with backend/module init or treat the dir as empty.

Solutions

  1. Inspect the working directory for unreadable subdirs: `find . -type d ! -readable`.
  2. Fix permissions on the offending directories (`chmod a+rx`).
  3. Remove broken symlinks and retry init.

Example fix

$ find . -type d ! -readable -exec chmod a+rx {} \; && terraform init
Defensive patterns

Strategy: validation

Validate before calling

// Find unreadable directories before init.
func, _ := filepath.WalkDir(".", func(p string, d fs.DirEntry, err error) error {
    if err == nil && d.IsDir() {
        f, e := os.Open(p)
        if e != nil { log.Printf("unreadable: %s", p) } else { f.Close() }
    }
    return nil
})

Prevention

When it happens

Trigger: Init's IsEmptyDir traversal fails due to permission denied on a subdirectory, I/O errors, or a broken symlink inside the working directory (including the tests directory).

Common situations: A submodule or test directory with restrictive permissions; stale symlink; NFS hiccup; .terraform dir corrupted.

Related errors


AI-assisted analysis of hashicorp/terraform@d32a084675 (2026-08-11). Data as JSON: /api/errors/a03665aa88210eac. Report an issue: GitHub.

Appendix: source

Thrown at internal/command/init_run.go:108

		initDirFromModuleAbort, initDirFromModuleDiags := c.initDirFromModule(ctx, path, src, hooks)
		diags = diags.Append(initDirFromModuleDiags)
		if initDirFromModuleAbort || initDirFromModuleDiags.HasErrors() {
			view.Diagnostics(diags)
			span.SetStatus(codes.Error, "module installation failed")
			span.End()
			return 1
		}
		span.End()

		view.Spacer()
	}

	// If our directory is empty, then we're done. We can't get or set up
	// the backend with an empty directory.
	empty, err := configs.IsEmptyDir(path, initArgs.TestsDirectory)
	if err != nil {
		diags = diags.Append(fmt.Errorf("Error checking configuration: %s", err))
		view.Diagnostics(diags)
		return 1
	}
	if empty {
		view.Output(views.OutputInitEmptyMessage)
		return 0
	}

	// Load just the root module to begin backend and module initialization
	rootModEarly, earlyConfDiags := c.loadSingleModuleWithTests(path, initArgs.TestsDirectory)

	// There may be parsing errors in config loading but these will be shown later _after_
	// checking for core version requirement errors. Not meeting the version requirement should
	// be the first error displayed if that is an issue, but other operations are required
	// before being able to check core version requirements.
	if rootModEarly == nil {
		diags = diags.Append(errors.New(errInitConfigError), earlyConfDiags)
		view.Diagnostics(diags)

View on GitHub (pinned to d32a084675)