hashicorp/terraform · error

error loading plugin path: %s

Error message

error loading plugin path: %s

What it means

Wrapped error from ShowCommand.Run when c.loadPluginPath() fails. loadPluginPath reads the plugin-path setting (from CLI config or .terraformrc) that augments where Terraform searches for provider plugins. If the file/setting cannot be parsed or the listed directories are invalid, 'terraform show' aborts before displaying state/plan. %s embeds the underlying error.

Source

Thrown at internal/command/show.go:90

	if err != nil {
		diags = diags.Append(err)
		view.Diagnostics(diags)
		return 1
	}

	var varDiags tfdiags.Diagnostics
	c.VariableValues, varDiags = args.Vars.CollectValues(func(filename string, src []byte) {
		loader.Parser().ForceFileSource(filename, src)
	})
	diags = diags.Append(varDiags)
	if varDiags.HasErrors() {
		view.Diagnostics(diags)
		return 1
	}

	// 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))
		view.Diagnostics(diags)
		return 1
	}

	// Get the data we need to display
	plan, jsonPlan, stateFile, config, schemas, showDiags := c.show(args.Path)
	diags = diags.Append(showDiags)
	if showDiags.HasErrors() {
		view.Diagnostics(diags)
		return 1
	}

	// Display the data
	return view.Display(config, plan, jsonPlan, stateFile, schemas)
}

func (c *ShowCommand) Help() string {
	helpText := `

View on GitHub (pinned to c9def3e214)

Solutions

  1. Inspect the embedded error for which plugin path entry is invalid.
  2. Correct or remove the plugin_path entry in ~/.terraformrc / TF_CLI_CONFIG_FILE.
  3. Ensure all listed plugin directories exist and are readable.
  4. Use 'terraform providers' / 'terraform init' with -plugin-dir instead of a global plugin_path.

Example fix

// before (~/.terraformrc)
plugin_cache_dir = "/old/path/that/gone"
// after
plugin_cache_dir = "/home/me/.terraform.d/plugin-cache"
Defensive patterns

Strategy: validation

Validate before calling

// Validate plugin_path entries in the CLI config are real, readable directories before 'terraform show'
package main

func preflightPluginPath(paths []string) error {
	for _, p := range paths {
		info, err := os.Stat(p)
		if err != nil { return fmt.Errorf("plugin path %s: %w", p, err) }
		if !info.IsDir() { return fmt.Errorf("plugin path %s is not a directory", p) }
	}
	return nil
}

Prevention

When it happens

Trigger: Running 'terraform show' when the plugin_path entry in the CLI config references a non-existent/unreadable directory or the config itself is malformed; loadPluginPath returns an error reading or validating those paths.

Common situations: plugin_path in ~/.terraformrc points to a directory that was moved/deleted; the CLI config has a syntax error in the plugin_paths array; permissions deny traversal of a listed path; container has stale plugin path from a different host.

Related errors


AI-assisted analysis of hashicorp/terraform@c9def3e214 (2026-08-07). Data as JSON: /api/errors/fca0d28c3fa65385. Report an issue: GitHub.