hashicorp/terraform · error

error loading plugin path

Error message

error loading plugin path: %s

What it means

ShowCommand.loadPluginPath (c.loadPluginPath()) reads the CLI plugin path configuration; if it errors, the message is wrapped, diagnostics shown, and the command returns 1. The plugin path feature (-plugin-dir) points Terraform at a filesystem mirror of providers, bypassing the registry; misconfiguration here aborts show.

Solutions

  1. Inspect ~/.terraformrc / TF_CLI_CONFIG_FILE plugin_path entries and verify each directory exists and is readable.
  2. Use absolute paths in plugin_path so resolution does not depend on cwd.
  3. Remove plugin_path if you intend to use the normal registry-based provider resolution.
  4. Ensure the mirror layout matches <hostname>/<namespace>/<name>/<version>/<platform>/.

Example fix

// before (~/.terraformrc)
plugin_path = ["./vendored-providers"]
// after
plugin_path = ["/opt/terraform/providers"]
Defensive patterns

Strategy: validation

Validate before calling

// Verify each plugin_path entry exists and is readable before running show.
for _, dir := range config.PluginPaths {
    if info, err := os.Stat(dir); err != nil || !info.IsDir() {
        return fmt.Errorf("plugin_path %s missing/unreadable", dir)
    }
}

Prevention

When it happens

Trigger: terraform show is run with TF_CLI_CONFIG_FILE / ~/.terraformrc containing a plugin_path block that references a non-existent, unreadable, or malformed directory, or with -plugin-dir pointing somewhere invalid.

Common situations: plugin_path set to a vendored mirror that was moved/deleted; relative path resolved against the wrong cwd; permission denied on the mirror dir; air-gapped install pointing plugin_path at an empty or wrongly-laid-out directory.

Related errors


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

Appendix: 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 d32a084675)