hashicorp/terraform · error
error loading plugin path: %s
Error message
error loading plugin path: %s
What it means
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.
Source
Thrown at internal/command/validate.go:79
var varDiags tfdiags.Diagnostics
c.VariableValues, varDiags = args.Vars.CollectValues(func(filename string, src []byte) {
loader.Parser().ForceFileSource(filename, src)
})
if varDiags.HasErrors() {
diags = diags.Append(varDiags)
return view.Results(diags)
}
dir, err := filepath.Abs(args.Path)
if err != nil {
diags = diags.Append(fmt.Errorf("unable to locate module: %s", err))
return view.Results(diags)
}
// Check for user-supplied plugin path
if c.pluginPath, err = c.loadPluginPath(); err != nil {
diags = diags.Append(fmt.Errorf("error loading plugin path: %s", err))
return view.Results(diags)
}
validateDiags := c.validate(dir)
diags = diags.Append(validateDiags)
// Validating with dev overrides in effect means that the result might
// not be valid for a stable release, so we'll warn about that in case
// the user is trying to use "terraform validate" as a sort of pre-flight
// check before submitting a change.
diags = diags.Append(c.providerDevOverrideRuntimeWarnings())
return view.Results(diags)
}
func (c *ValidateCommand) validate(dir string) tfdiags.Diagnostics {
var diags tfdiags.Diagnostics
var cfg *configs.ConfigView on GitHub (pinned to c9def3e214)
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.
Example fix
# before terraform validate # error loading plugin path: invalid character 'x'... # after rm .terraform/.terraformrc_plugin_path terraform init terraform validate
Defensive patterns
Strategy: validation
Validate before calling
// validate the forced plugin path marker before validate runs
func validateForcedPluginDirs(path string) error {
raw, err := os.ReadFile(path)
if os.IsNotExist(err) { return nil }
if err != nil { return err }
var dirs []string
return json.Unmarshal(raw, &dirs)
} Prevention
- 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.
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- error loading plugin path: %s
- Failed to load state: %s
- unable to locate module: %s
- invalid syntax: %w
- error deleting workspace %s: %w
AI-assisted analysis of hashicorp/terraform@c9def3e214 (2026-08-07).
Data as JSON: /api/errors/75a0c4a091be675b.
Report an issue: GitHub.