│ Error: Failed to load state: unsupported backend state version 4; you may need to use Terraform CLI v1.12.0 to work in this directory
| terraform version
Terraform v1.12.0
on darwin_amd64
│ Error: Failed to load state: unsupported backend state version 4; you may need to use Terraform CLI v1.12.0 to work in this directory
| terraform version
Terraform v1.12.0
on darwin_amd64
Hi @triggerazura,
This error message refers to the “backend state”, which is the somewhat-confusing terminology Terraform uses to refer to the .terraform/terraform.tfstate
file that is used to track the active backend settings. This is not actually a state file directly, but rather tells Terraform how to contact the state storage to obtain the real state.
That file is supposed to be version 3 even on modern Terraform, so I think the main question here is how you’ve ended up with a version 4 recorded in .terraform/terraform.tfstate
. As far as I know Terraform would not naturally generate that file with version 4 recorded, since the format version of that file is still version 3.
Do you remember running any commands that might have overwritten that file with a normal state snapshot, rather than a “backend state” file? For example, running terraform state pull
and redirecting its output to .terraform/terraform.tfstate
could cause this situation, but it isn’t correct to overwrite the “backend state” with a real state snapshot, because these two formats have distinct purposes.