{"record":{"id":"f4a17611c9256fcc","repo":"hashicorp/terraform","slug":"no-more-than-one-provider-installation-block-may-b","errorCode":null,"errorMessage":"No more than one provider_installation block may be specified","messagePattern":"No more than one provider_installation block may be specified","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/command/cliconfig/cliconfig.go","lineNumber":323,"sourceCode":"\t\t_, err := svchost.ForComparison(givenHost)\n\t\tif err != nil {\n\t\t\tdiags = diags.Append(\n\t\t\t\tfmt.Errorf(\"The credentials %q block has an invalid hostname: %s\", givenHost, err),\n\t\t\t)\n\t\t}\n\t}\n\n\t// Should have zero or one \"credentials_helper\" blocks\n\tif len(c.CredentialsHelpers) > 1 {\n\t\tdiags = diags.Append(\n\t\t\tfmt.Errorf(\"No more than one credentials_helper block may be specified\"),\n\t\t)\n\t}\n\n\t// Should have zero or one \"provider_installation\" blocks\n\tif len(c.ProviderInstallation) > 1 {\n\t\tdiags = diags.Append(\n\t\t\tfmt.Errorf(\"No more than one provider_installation block may be specified\"),\n\t\t)\n\t}\n\n\tif c.PluginCacheDir != \"\" {\n\t\t_, err := os.Stat(c.PluginCacheDir)\n\t\tif err != nil {\n\t\t\tdiags = diags.Append(\n\t\t\t\tfmt.Errorf(\"The specified plugin cache dir %s cannot be opened: %s\", c.PluginCacheDir, err),\n\t\t\t)\n\t\t}\n\t}\n\n\treturn diags\n}\n\n// Merge merges two configurations and returns a third entirely\n// new configuration with the two merged.\nfunc (c *Config) Merge(c2 *Config) *Config {","sourceCodeStart":305,"sourceCodeEnd":341,"githubUrl":"https://github.com/hashicorp/terraform/blob/c9def3e214014c1188faabfc4a5bde5095139765/internal/command/cliconfig/cliconfig.go#L305-L341","documentation":"Emitted by `Config.Validate` (cliconfig.go:321-324) when more than one `provider_installation` block exists across the merged CLI config. `Config.ProviderInstallation` is a slice precisely so this count can be validated; only one such block (containing multiple method blocks) is permitted.","triggerScenarios":"Two `provider_installation { ... }` blocks anywhere in the loaded CLI config (`.terraformrc` and/or any `*.tfrc`/`*.tfrc.json` in the config dir), which the Merge step appends into a single slice.","commonSituations":"Maintaining separate `provider_installation` blocks in different files that both get merged; copy-pasting a dev-overrides config alongside an existing filesystem-implied installation config.","solutions":["Consolidate into a single `provider_installation` block and put multiple `direct`, `filesystem_mirror`, `network_mirror`, or `dev_overrides` blocks inside it.","Audit every file Terraform loads for the CLI config and remove extras.","Re-run `terraform init` to confirm `Validate` passes."],"exampleFix":"# before\nprovider_installation {\n  filesystem_mirror { path = \"/opt/mirror\" }\n}\nprovider_installation {\n  dev_overrides { \"hashicorp/aws\" = \"/src/aws\" }\n}\n# No more than one provider_installation block may be specified\n\n# after (merge method blocks into one)\nprovider_installation {\n  filesystem_mirror { path = \"/opt/mirror\" }\n  dev_overrides { \"hashicorp/aws\" = \"/src/aws\" }\n}","handlingStrategy":"validation","validationCode":"// Ensure only one provider_installation block exists across CLI config.\nfunc countProviderInstallation(files []string) int {\n    n := 0\n    for _, f := range files {\n        b, _ := os.ReadFile(f)\n        if bytes.Contains(b, []byte(\"provider_installation\")) {\n            n++\n        }\n    }\n    return n\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Put multiple installation methods inside a single `provider_installation` block.","Search every loaded file for the block before combining configs.","Avoid splitting dev_overrides into its own top-level block."],"tags":["terraform","cli-config","provider-installation","validation","duplicate"],"analyzedSha":"c9def3e214014c1188faabfc4a5bde5095139765","analyzedAt":"2026-08-07T15:39:49.278Z","schemaVersion":2},"datasetVersion":"2026-08-07T21:17:07.882Z"}