hashicorp/terraform · error
Error checking configuration: %s
Error message
Error checking configuration: %s
What it means
Emitted by InitCommand.run when configs.IsEmptyDir(path, testsDir) errors while checking whether the working directory contains any configuration (init_run.go:106-108). This check gates the rest of init: if it cannot determine emptiness, init aborts before loading config. The %s is the underlying IsEmptyDir error.
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 c9def3e214)
Solutions
- Make the working directory (and any -test-directory) readable+traversable by the terraform user.
- Fix or remove broken symlinks and stale .terraform artifacts.
- Confirm the test directory passed to -test-directory exists and is readable.
- Restore the underlying filesystem to a healthy state and retry init.
Example fix
# before $ terraform init # cwd not stat-able # after $ chmod a+rx . $ terraform init
Defensive patterns
Strategy: validation
Validate before calling
// Confirm the working dir and test dir are stat-able before init.
for _, d := range []string{wd, testDir} {
if _, err := os.Stat(d); err != nil {
return fmt.Errorf("cannot stat %q: %w", d, err)
}
} Prevention
- Run init in a working directory the terraform user can read and traverse.
- Make sure -test-directory points to an existing, readable path.
- Avoid running init against directories with broken symlinks or on failing mounts.
When it happens
Trigger: Running `terraform init` in a working directory that exists but where Terraform cannot walk/stat its contents: permission denied on the dir or a child entry, I/O errors, broken symlinks, or the test directory argument (-test-directory) points somewhere unreadable.
Common situations: Read-only or foreign-owned working directories; .terraform/.tftest directories created by root; corporate mount permission issues; full/ failing disks; misconfigured -test-directory pointing at an inaccessible path.
Related errors
- Error saving -plugin-dir to workspace directory: %s
- Error validating destination directory: %s
- error deleting workspace %s: %w
- cannot create temporary file to update credentials: %s
- could not write lock info for %q: %s
AI-assisted analysis of hashicorp/terraform@c9def3e214 (2026-08-07).
Data as JSON: /api/errors/a03665aa88210eac.
Report an issue: GitHub.