How to fix Error: Inconsistent dependency lock file in Terraform

TerraformBEGINNERMEDIUMUpdated Dec 30, 2025ยท 134 views

The .terraform.lock.hcl file has become out of sync with your provider requirements, typically due to platform differences or manual edits. This error prevents Terraform from proceeding until the lock file is regenerated or updated.

Quick fix

Fixes Error: Inconsistent dependency lock file

rm .terraform.lock.hcl
terraform init
  1. Delete and regenerate the lock file
  2. Generate lock file for all team platforms
  3. Commit the regenerated lock file
  4. Verify lock file consistency across your team
terraform โ€” error
rm .terraform.lock.hcl
terraform init
Error: Inconsistent dependency lock file

What this error means

Terraform uses the .terraform.lock.hcl file to lock provider versions and ensure consistent deployments across your team. When this file becomes inconsistent with your provider configuration, Terraform detects a mismatch and refuses to proceed. This typically happens when the lock file was created on one platform (e.g., macOS) but is being used on another (e.g., Linux), or when the provider versions in your configuration have changed without the lock file being updated. The lock file contains provider version numbers and checksums for each platform architecture your team uses.

Typical symptoms

  • Terraform init fails with 'inconsistent dependency lock file' error
  • Error occurs on a different OS or architecture than where lock file was created
  • Manual edits to .terraform.lock.hcl cause validation failures
  • Provider versions in configuration don't match lock file entries
  • CI/CD pipelines fail when running Terraform on a different platform than the developer's machine

Common causes

  1. Lock file was generated on a different OS or architecture (macOS vs Linux, Intel vs ARM) without including all target platforms
  2. Provider version constraints in your Terraform code changed but the lock file wasn't regenerated
  3. Manual editing or corruption of the .terraform.lock.hcl file
  4. Developers using different Terraform versions to run terraform providers lock
  5. Lock file was not committed to version control, causing each developer to have different versions

How to fix "Error: Inconsistent dependency lock file"

1Delete and regenerate the lock file

Remove the inconsistent lock file and let Terraform regenerate it with correct checksums:

bash
rm .terraform.lock.hcl
terraform init

This creates a new lock file with providers for your current platform.

2Generate lock file for all team platforms

If your team uses multiple platforms, generate lock entries for all of them at once:

bash
terraform providers lock -platform=linux_amd64 -platform=darwin_amd64 -platform=darwin_arm64 -platform=windows_amd64

This ensures every developer and CI/CD pipeline uses the same provider versions regardless of OS.

3Commit the regenerated lock file

Always commit .terraform.lock.hcl to version control:

bash
git add .terraform.lock.hcl
git commit -m 'Regenerate Terraform lock file with all platform checksums'

This ensures all team members and CI/CD systems use identical provider versions.

4Verify lock file consistency across your team

Have all team members run terraform init to verify they can read the lock file without errors:

bash
terraform init

If any developer gets inconsistency errors on their platform, repeat steps 1-2 to include their platform in the lock file.

Advanced notes

The .terraform.lock.hcl file format includes provider source, version, and a checksum (h1 hash) for each platform. Different OS/architecture combinations require different checksums because binary packages differ. When you run 'terraform providers lock' with multiple -platform flags, Terraform downloads and checksums the provider package for each platform, even if you're not currently on that platform. This is why it's important to run this command before committing to ensure all team members and CI/CD pipelines have consistent lock entries. For teams using both Intel and ARM Macs (darwin_amd64 vs darwin_arm64), including both platforms is essential. If you only included darwin_amd64 in the lock file but someone on your team uses an M1/M2 Mac (darwin_arm64), they'll get this error. Similarly, if CI/CD runs on Linux but developers use macOS, both platforms must be in the lock file.

Frequently asked questions

What does "Error: Inconsistent dependency lock file" mean?
hcl file to lock provider versions and ensure consistent deployments across your team. When this file becomes inconsistent with your provider configuration, Terraform detects a mismatch and refuses to proceed. , Linux), or when the provider versions in your configuration have changed without the lock file being updated.
How do I fix "Error: Inconsistent dependency lock file"?
The .terraform.lock.hcl file has become out of sync with your provider requirements, typically due to platform differences or manual edits. This error prevents Terraform from proceeding until the lock file is regenerated or updated.
What causes "Error: Inconsistent dependency lock file"?
Lock file was generated on a different OS or architecture (macOS vs Linux, Intel vs ARM) without including all target platforms Provider version constraints in your Terraform code changed but the lock file wasn't regenerated Manual editing or corruption of the .terraform.lock.hcl file
Is the "Error: Inconsistent dependency lock file" error serious?
It is a medium-severity error โ€” more of a blocker than a risk. The steps above resolve it.

Official resources & further reading