terraform
config_error
ai_generated
true
Error: Invalid required_providers version constraint: "~> 3.0, < 4.0" is not a valid version constraint string
ID: terraform/invalid-required-providers-version-constraint
90%Fix Rate
88%Confidence
1Evidence
2024-08-20First Seen
Version Compatibility
| Version | Status | Introduced | Deprecated | Notes |
|---|---|---|---|---|
| Terraform v1.5.0 | active | — | — | — |
| Terraform v1.6.0 | active | — | — | — |
| Terraform v1.7.0 | active | — | — | — |
Root Cause
The version constraint syntax in required_providers is malformed or uses unsupported operators.
generic中文
required_providers 中的版本约束语法格式错误或使用了不支持的运算符。
Official Documentation
https://developer.hashicorp.com/terraform/language/providers/requirementsWorkarounds
-
95% success Use a single constraint without commas: `version = "~> 3.0"` or use multiple constraints with newlines: `version = [">= 3.0", "< 4.0"]`
Use a single constraint without commas: `version = "~> 3.0"` or use multiple constraints with newlines: `version = [">= 3.0", "< 4.0"]`
-
95% success Correct the syntax to use a list: `version = [">= 3.0", "< 4.0"]` and run 'terraform init'
Correct the syntax to use a list: `version = [">= 3.0", "< 4.0"]` and run 'terraform init'
中文步骤
Use a single constraint without commas: `version = "~> 3.0"` or use multiple constraints with newlines: `version = [">= 3.0", "< 4.0"]`
Correct the syntax to use a list: `version = [">= 3.0", "< 4.0"]` and run 'terraform init'
Dead Ends
Common approaches that don't work:
-
Remove the version constraint entirely and run terraform init
60% fail
Without constraints, Terraform may install a newer incompatible provider version.
-
Use a comma instead of spaces between constraints: "~> 3.0,< 4.0"
90% fail
The comma is still invalid; Terraform requires spaces or newlines between constraints.
-
Wrap the constraint in double quotes inside the block
50% fail
The error is about the constraint string syntax, not quoting.