{"record":{"id":"e5fa7e1b5715042f","repo":"getsops/sops","slug":"config-file-not-found","errorCode":null,"errorMessage":"config file not found","messagePattern":"config file not found","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"config/config.go","lineNumber":93,"sourceCode":"\t\t\talternatePath := path.Join(filepath, alternateConfigName)\n\t\t\t_, altErr := fs.Stat(alternatePath)\n\t\t\tif altErr == nil {\n\t\t\t\tfoundAlternatePath = alternatePath\n\t\t\t}\n\t\t}\n\n\t\tfilepath = path.Join(filepath, \"..\")\n\t}\n\n\t// No config file found\n\tresult := ConfigFileResult{}\n\tif foundAlternatePath != \"\" {\n\t\tresult.Warning = fmt.Sprintf(\n\t\t\t\"ignoring %q when searching for config file; the config file must be called %q\",\n\t\t\tfoundAlternatePath, configFileName)\n\t}\n\n\treturn result, fmt.Errorf(\"config file not found\")\n}\n\n// FindConfigFile looks for a sops config file in the current working directory and on parent directories, up to the limit defined by the maxDepth constant.\nfunc FindConfigFile(start string) (string, error) {\n\tresult, err := LookupConfigFile(start)\n\treturn result.Path, err\n}\n\ntype DotenvStoreConfig struct{}\n\ntype INIStoreConfig struct{}\n\ntype JSONStoreConfig struct {\n\tIndent int `yaml:\"indent\"`\n}\n\ntype JSONBinaryStoreConfig struct {\n\tIndent int `yaml:\"indent\"`","sourceCodeStart":75,"sourceCodeEnd":111,"githubUrl":"https://github.com/getsops/sops/blob/13442bb98183887d7a9ac09ec8ab0564673a59d8/config/config.go#L75-L111","documentation":"LookupConfigFile walks up to 100 parent directories from the starting path looking for `.sops.yaml` and returns this error when none exists anywhere in the chain. It is a normal 'no configuration found' result, not a parse failure; note `.sops.yml` is intentionally not accepted and only produces a warning.","triggerScenarios":"Calling sops (or FindConfigFile/LookupConfigFile) from a directory tree that contains no `.sops.yaml` in the working directory or any ancestor up to the 100-directory limit.","commonSituations":"Running sops in a fresh checkout or CI workspace where the config file was never committed, config file named `.sops.yml` (wrong extension) which sops deliberately ignores, running from a subdirectory above the repo root containing the config, file renamed to `sops.yaml` without the leading dot.","solutions":["Create a `.sops.yaml` at the project root (or cd into the directory containing the existing one)","Rename `.sops.yml` to `.sops.yaml` — the .yml extension is explicitly ignored with a warning","Verify the file is committed/present in CI (not in .gitignore) and that you run sops from within the repo tree","Pass the config explicitly if supported by your workflow, or rely on per-file CLI flags instead of config lookup"],"exampleFix":"# before\nmv .sops.yml .sops.yaml.bak  # wrong name/location\n# after\ncd /path/to/repo && test -f .sops.yaml || cat > .sops.yaml <<'EOF'\ncreation_rules:\n  - path_regex: .*secrets.*\n    age: age1xxxxxxxx\nEOF","handlingStrategy":"fallback","validationCode":"// before running sops\ntest -f .sops.yaml || { echo \"no .sops.yaml found from $(pwd) upward\"; ls ../.sops.yaml 2>/dev/null; }","typeGuard":null,"tryCatchPattern":"path, err := config.FindConfigFile(\".\")\nif err != nil {\n\tif err.Error() == \"config file not found\" {\n\t\t// proceed with CLI-flag-only encryption or create a default .sops.yaml\n\t\treturn nil\n\t}\n\treturn err\n}","preventionTips":["Always commit .sops.yaml at the repo root (never gitignore it)","Use .sops.yaml, never .sops.yml — the alternate name is deliberately ignored","Run sops from within the repository tree containing the config","Add a pre-flight check in CI: `test -f .sops.yaml`"],"tags":["configuration","sops","file-not-found"],"backgroundTag":"config-file-not-found","analyzedSha":"13442bb98183887d7a9ac09ec8ab0564673a59d8","analyzedAt":"2026-09-01T03:53:00.447Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}