{"record":{"id":"75a0c4a091be675b","repo":"hashicorp/terraform","slug":"error-loading-plugin-path-s-75a0c4","errorCode":null,"errorMessage":"error loading plugin path: %s","messagePattern":"error loading plugin path: (.+?)","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/command/validate.go","lineNumber":79,"sourceCode":"\n\tvar varDiags tfdiags.Diagnostics\n\tc.VariableValues, varDiags = args.Vars.CollectValues(func(filename string, src []byte) {\n\t\tloader.Parser().ForceFileSource(filename, src)\n\t})\n\tif varDiags.HasErrors() {\n\t\tdiags = diags.Append(varDiags)\n\t\treturn view.Results(diags)\n\t}\n\n\tdir, err := filepath.Abs(args.Path)\n\tif err != nil {\n\t\tdiags = diags.Append(fmt.Errorf(\"unable to locate module: %s\", err))\n\t\treturn view.Results(diags)\n\t}\n\n\t// Check for user-supplied plugin path\n\tif c.pluginPath, err = c.loadPluginPath(); err != nil {\n\t\tdiags = diags.Append(fmt.Errorf(\"error loading plugin path: %s\", err))\n\t\treturn view.Results(diags)\n\t}\n\n\tvalidateDiags := c.validate(dir)\n\tdiags = diags.Append(validateDiags)\n\n\t// Validating with dev overrides in effect means that the result might\n\t// not be valid for a stable release, so we'll warn about that in case\n\t// the user is trying to use \"terraform validate\" as a sort of pre-flight\n\t// check before submitting a change.\n\tdiags = diags.Append(c.providerDevOverrideRuntimeWarnings())\n\n\treturn view.Results(diags)\n}\n\nfunc (c *ValidateCommand) validate(dir string) tfdiags.Diagnostics {\n\tvar diags tfdiags.Diagnostics\n\tvar cfg *configs.Config","sourceCodeStart":61,"sourceCodeEnd":97,"githubUrl":"https://github.com/hashicorp/terraform/blob/c9def3e214014c1188faabfc4a5bde5095139765/internal/command/validate.go#L61-L97","documentation":"Thrown by `terraform validate` when c.loadPluginPath() returns an error — identical mechanism to the state-show plugin-path error. loadPluginPath calls WorkingDir.ForcedPluginDirs(), which reads the forced plugin directories marker file; it errors if that file exists but cannot be read or fails to JSON-unmarshal. The %s is the underlying error.","triggerScenarios":"Running `terraform validate` when the forced-plugin-dirs file (.terraform marker written by `terraform init -plugin-dir`) exists but is unreadable or contains malformed JSON.","commonSituations":"Corrupt plugin-path file from an interrupted init; permission change on .terraform/; file synced/truncated by cloud storage; Terraform version mismatch writing an incompatible format.","solutions":["Validate the forced plugin path file is a JSON array of strings, or delete it.","Re-run `terraform init` (without -plugin-dir if you want defaults) to regenerate the marker.","Fix .terraform permissions so the current user can read it, then re-run validate."],"exampleFix":"# before\nterraform validate\n# error loading plugin path: invalid character 'x'...\n\n# after\nrm .terraform/.terraformrc_plugin_path\nterraform init\nterraform validate","handlingStrategy":"validation","validationCode":"// validate the forced plugin path marker before validate runs\nfunc validateForcedPluginDirs(path string) error {\n    raw, err := os.ReadFile(path)\n    if os.IsNotExist(err) { return nil }\n    if err != nil { return err }\n    var dirs []string\n    return json.Unmarshal(raw, &dirs)\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Regenerate the forced plugin path marker via `terraform init` if you change -plugin-dir.","Keep .terraform/ readable.","Avoid tools that corrupt or truncate marker files.","Don't switch Terraform versions with incompatible marker formats without re-init."],"tags":["validate","plugin-path","json","filesystem"],"analyzedSha":"c9def3e214014c1188faabfc4a5bde5095139765","analyzedAt":"2026-08-07T15:39:49.278Z","schemaVersion":2},"datasetVersion":"2026-08-07T21:17:07.882Z"}