{"record":{"id":"757e8d7d5a1d51a4","repo":"hashicorp/terraform","slug":"there-is-no-configuration-directory-at-s","errorCode":null,"errorMessage":"There is no configuration directory at %s","messagePattern":"There is no configuration directory at (.+?)","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/command/fmt.go","lineNumber":239,"sourceCode":"\t\t_, err = w.Write(result)\n\t\tif err != nil {\n\t\t\tdiags = diags.Append(fmt.Errorf(\"Failed to write result\"))\n\t\t}\n\t}\n\n\treturn diags\n}\n\nfunc (c *FmtCommand) processDir(path string, stdout io.Writer) tfdiags.Diagnostics {\n\tvar diags tfdiags.Diagnostics\n\n\tlog.Printf(\"[TRACE] terraform fmt: looking for files in %s\", path)\n\n\tentries, err := os.ReadDir(path)\n\tif err != nil {\n\t\tswitch {\n\t\tcase os.IsNotExist(err):\n\t\t\tdiags = diags.Append(fmt.Errorf(\"There is no configuration directory at %s\", path))\n\t\tdefault:\n\t\t\t// ReadDir does not produce error messages that are end-user-appropriate,\n\t\t\t// so we'll need to simplify here.\n\t\t\tdiags = diags.Append(fmt.Errorf(\"Cannot read directory %s\", path))\n\t\t}\n\t\treturn diags\n\t}\n\n\tfor _, info := range entries {\n\t\tname := info.Name()\n\t\tif configs.IsIgnoredFile(name) {\n\t\t\tcontinue\n\t\t}\n\t\tsubPath := filepath.Join(path, name)\n\t\tif info.IsDir() {\n\t\t\tif c.recursive {\n\t\t\t\tsubDiags := c.processDir(subPath, stdout)\n\t\t\t\tdiags = diags.Append(subDiags)","sourceCodeStart":221,"sourceCodeEnd":257,"githubUrl":"https://github.com/hashicorp/terraform/blob/c9def3e214014c1188faabfc4a5bde5095139765/internal/command/fmt.go#L221-L257","documentation":"Emitted by terraform fmt's processDir when os.ReadDir reports the target path does not exist (os.IsNotExist). It is a user-facing simplification because the raw ReadDir error is not end-user appropriate. The %s is the normalized path argument passed to `terraform fmt`. The command continues processing other paths but records this diagnostic.","triggerScenarios":"Invoking `terraform fmt <dir>` or `terraform fmt -recursive <dir>` where <dir> does not exist on disk. Also when a relative path resolves against an unexpected working directory (e.g. running fmt from the wrong cwd, a typo in the path, or a path to a directory that was deleted).","commonSituations":"Typos in the directory argument; running `terraform fmt ./moodules` instead of `./modules`. CI jobs that cd into a non-existent directory before invoking fmt. Scripts that build the path from an unset variable, yielding an empty/missing segment. Renaming a module directory without updating the fmt script.","solutions":["Verify the path exists and is spelled correctly: `ls <dir>` before running fmt.","Omit the argument to operate on the current directory (`terraform fmt`) which always exists.","In scripts, guard with a check: `[ -d \"$DIR\" ] && terraform fmt \"$DIR\"`.","Fix the working directory / variable expansion that produced the bogus path."],"exampleFix":"# before\n$ terraform fmt ./moodules\n# after\n$ terraform fmt ./modules","handlingStrategy":"validation","validationCode":"// Verify the directory exists before calling terraform fmt on it.\nif info, err := os.Stat(dir); err != nil || !info.IsDir() {\n    return fmt.Errorf(\"refusing to fmt: %q is not an existing directory\", dir)\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always resolve fmt path arguments against a known working directory.","In scripts, guard with `[ -d \"$DIR\" ]` before invoking terraform fmt.","Default to running `terraform fmt` with no argument (current dir) to avoid path typos."],"tags":["terraform-fmt","filesystem","path","missing-directory"],"analyzedSha":"c9def3e214014c1188faabfc4a5bde5095139765","analyzedAt":"2026-08-07T15:39:49.278Z","schemaVersion":2},"datasetVersion":"2026-08-07T21:17:07.882Z"}