How to fix Error: Inconsistent dependency lock file in Terraform
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- Delete and regenerate the lock file
- Generate lock file for all team platforms
- Commit the regenerated lock file
- Verify lock file consistency across your team
rm .terraform.lock.hclterraform initError: 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
- 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
- Developers using different Terraform versions to run terraform providers lock
- Lock file was not committed to version control, causing each developer to have different versions
How to fix "Error: Inconsistent dependency lock file"
Remove the inconsistent lock file and let Terraform regenerate it with correct checksums:
rm .terraform.lock.hcl
terraform initThis creates a new lock file with providers for your current platform.
If your team uses multiple platforms, generate lock entries for all of them at once:
terraform providers lock -platform=linux_amd64 -platform=darwin_amd64 -platform=darwin_arm64 -platform=windows_amd64This ensures every developer and CI/CD pipeline uses the same provider versions regardless of OS.
Always commit .terraform.lock.hcl to version control:
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.
Have all team members run terraform init to verify they can read the lock file without errors:
terraform initIf 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.