Inconsistent dependency lock file 🟪 Terraform

Terraform: Error: Inconsistent dependency lock file — provider x: required by this configuration but no version is selected

The .terraform.lock.hcl file doesn’t match the providers/versions your configuration now requires, or init wasn’t run.

Seen on: Terraform

Meaning

Adding a provider, changing version constraints, or switching platforms (lock file only has hashes for one OS) requires terraform init -upgrade or providers lock for all platforms.

Common causes

  • Provider added/changed without terraform init
  • Lock file missing hashes for the CI platform (darwin vs linux)
  • Version constraint changed
  • .terraform directory stale

⚡ Quick fix

  1. Run terraform init -upgrade and commit the lock file
  2. Add hashes for all platforms with terraform providers lock
  3. Delete .terraform/ and init again

Detailed fix by platform

Shell

  1. hcl
    terraform init -upgrade
    terraform providers lock -platform=linux_amd64 -platform=darwin_arm64 -platform=windows_amd64

How to diagnose

  1. Lock — Providers listed
  2. Platforms — Hashes for CI OS?
  3. Init — Run after change?

🔧 Still not fixed?

Many errors look alike. If the steps above didn’t solve it, one of these is probably what you’re facing:

🧠 Still stuck? Analyze your error

Paste the full message, response headers or stack trace — we'll detect the platform and point to the most likely cause.