hashicorp/terraform · error
error loading plugin path
Error message
error loading plugin path: %s
What it means
Thrown by validate.go when c.loadPluginPath() returns an error during `terraform validate`. Identical mechanism to [754]: a user-supplied plugin_directory (CLI config or -plugin-dir) is invalid, missing, or unreadable. Wrapped with %s.
Solutions
- Inspect ~/.terraformrc / TF_CLI_CONFIG_FILE for `plugin_directory` and validate the path.
- Drop `-plugin-dir` and run `terraform init` to install providers normally.
- Recreate the plugin cache: `terraform providers lock` then `terraform init`.
- Fix permissions on the configured plugin directory.
Example fix
# before terraform validate -plugin-dir=/opt/tf-plugins # after rm ~/.terraformrc # or fix plugin_directory terraform init terraform validate
Defensive patterns
Strategy: validation
Validate before calling
// Validate plugin_directory before validate.
if c.pluginPath != "" {
if info, err := os.Stat(c.pluginPath); err != nil || !info.IsDir() {
return fmt.Errorf("plugin_directory %s invalid: %w", c.pluginPath, err)
}
} Try / catch
if c.pluginPath, err = c.loadPluginPath(); err != nil {
diags = diags.Append(fmt.Errorf("error loading plugin path: %s; remove plugin_directory from CLI config or fix path", err))
return view.Results(diags)
} Prevention
- Drop `plugin_directory` from ~/.terraformrc if unused.
- Run `terraform init` before `terraform validate` to populate the plugin cache.
- Use absolute paths for plugin caches in CI.
- Re-create any vendored plugin dir before invoking validate.
When it happens
Trigger: `terraform validate` invoked with a configured plugin_directory that does not exist, is not a directory, is unreadable, or fails validation when Terraform scans its contents.
Common situations: Vendored plugin directory removed by `make clean` or git clean; CI image missing the plugin cache volume; ~/.terraformrc `plugin_directory` left over from a different machine; -plugin-dir passed with a typo.
Related errors
- error loading plugin path
- error loading plugin path
- failed to create stacks plugin stored path file
- failed to initialize stacksplugin cache directory
- failed to read stacks plugin stored path file
AI-assisted analysis of hashicorp/terraform@d32a084675 (2026-08-11).
Data as JSON: /api/errors/75a0c4a091be675b.
Report an issue: GitHub.
Appendix: 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 d32a084675)