{"record":{"id":"6f7c6c07f35bbca8","repo":"hashicorp/terraform","slug":"error-reading-s-s","errorCode":null,"errorMessage":"Error reading %s: %s","messagePattern":"Error reading (.+?): (.+?)","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/command/cliconfig/cliconfig.go","lineNumber":160,"sourceCode":"\t\tconfig = envConfig.Merge(config)\n\t}\n\n\tdiags = diags.Append(config.Validate())\n\n\treturn config, diags\n}\n\n// loadConfigFile loads the CLI configuration from \".terraformrc\" files.\nfunc loadConfigFile(path string) (*Config, tfdiags.Diagnostics) {\n\tvar diags tfdiags.Diagnostics\n\tresult := &Config{}\n\n\tlog.Printf(\"Loading CLI configuration from %s\", path)\n\n\t// Read the HCL file and prepare for parsing\n\td, err := ioutil.ReadFile(path)\n\tif err != nil {\n\t\tdiags = diags.Append(fmt.Errorf(\"Error reading %s: %s\", path, err))\n\t\treturn result, diags\n\t}\n\n\t// Parse it\n\tobj, err := hcl.Parse(string(d))\n\tif err != nil {\n\t\tdiags = diags.Append(fmt.Errorf(\"Error parsing %s: %s\", path, err))\n\t\treturn result, diags\n\t}\n\n\t// Build up the result\n\tif err := hcl.DecodeObject(&result, obj); err != nil {\n\t\tdiags = diags.Append(fmt.Errorf(\"Error parsing %s: %s\", path, err))\n\t\treturn result, diags\n\t}\n\n\t// Deal with the provider_installation block, which is not handled using\n\t// DecodeObject because its structure is not compatible with the","sourceCodeStart":142,"sourceCodeEnd":178,"githubUrl":"https://github.com/hashicorp/terraform/blob/d32a084675427f5ac3f7d2868578ef8b2c1dc525/internal/command/cliconfig/cliconfig.go#L142-L178","documentation":"Thrown when Terraform cannot read a CLI configuration file (.terraformrc or .tfrc) at the filesystem level. ioutil.ReadFile returns an error which is wrapped with the file path. This is distinct from parsing errors (549, 550) — the file could not even be opened for reading.","triggerScenarios":"loadConfigFile(path) calls ioutil.ReadFile(path) which fails because the file does not exist at the resolved path, permissions are denied, the path points to a directory, or an I/O error occurs.","commonSituations":"TF_CLI_CONFIG_FILE points to a nonexistent file; ~/.terraformrc has wrong permissions; file was deleted or moved; running as a different user whose HOME differs; broken symlinks in the config path.","solutions":["Verify the config file path exists: ls -la <path>","Check file permissions: chmod 644 ~/.terraformrc","Ensure TF_CLI_CONFIG_FILE (if set) points to an existing, readable file","Check for broken symlinks in the config path"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// Check config file exists and is readable before relying on it\nfunc checkConfigFile(path string) error {\n    info, err := os.Stat(path)\n    if err != nil {\n        return fmt.Errorf(\"config file %s not accessible: %w\", path, err)\n    }\n    if info.IsDir() {\n        return fmt.Errorf(\"config path %s is a directory, not a file\", path)\n    }\n    return nil\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Verify TF_CLI_CONFIG_FILE points to an existing file","Ensure ~/.terraformrc has read permissions for the running user","Check for broken symlinks in the home directory path","Use terraform's verbose logging (TF_LOG=DEBUG) to trace which config path is being read"],"tags":["cli-config","filesystem","terraformrc","permissions"],"backgroundTag":null,"analyzedSha":"d32a084675427f5ac3f7d2868578ef8b2c1dc525","analyzedAt":"2026-08-11T18:43:52.779Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}