VectleSkillsError: Inconsistent dependency lock file: "no version is selected" after adding a provider

Error: Inconsistent dependency lock file: "no version is selected" after adding a provider

Export

Fixes Terraform's "Error: Inconsistent dependency lock file ... no version is selected", which appears after adding a provider or module without re-running init. Use when terraform init fails on lock selections. Not for registry constraint errors ("Failed to query available provider packages").

TL;DR

Your .terraform.lock.hcl does not cover a provider your configuration now requires. That happens when you add a provider (or a module that needs one) after the last terraform init. Run terraform init -upgrade to record the new selection, commit the lock file, and move on.

The error

Error: Inconsistent dependency lock file

- provider registry.terraform.io/hashicorp/random: required by this
  configuration but no version is selected

Another common shape:

Error: Inconsistent dependency lock file. The following dependency selections recorded in the lock file are inconsistent...

Steps to fix

  1. Confirm the cause: you (or a merged PR) added a provider to required_providers or added a module that pulls one in, without re-running init.
  • Expected: git log --oneline -3 -- .terraform.lock.hcl shows the lock file is older than the config change.
  1. Run terraform init -upgrade.
  • Expected: Terraform selects versions for the new providers and rewrites .terraform.lock.hcl. init succeeds.
  1. Commit the updated .terraform.lock.hcl.
  • Expected: git status shows the lock file modified; CI will now use the same selections.
  1. Run terraform plan to confirm everything resolves.
  • Expected: plan starts without lock errors.

When to use this

  • terraform init fails with Inconsistent dependency lock file after adding a provider, adding a module, or pulling a branch that did either.

When NOT to use this

  • Failed to query available provider packages means the registry cannot satisfy your version constraints (a constraint problem, not a lock problem). If the lock file is committed and CI still fails, the committed file is stale: regenerate it locally and commit.

Compatibility

  • Terraform 0.14+ (lock file introduced). -upgrade behavior is stable across 1.x.

Root cause

The lock file pins the exact provider versions and hashes your configuration resolved to. Adding a new provider requirement makes the recorded selections incomplete, and Terraform refuses to guess: it errors rather than silently picking a version that might differ from what a teammate gets.

Edge cases

  • If your repo gitignores .terraform.lock.hcl, every fresh clone re-resolves and you lose reproducibility; commit the lock file instead.
  • terraform init -upgrade upgrades everything; to add one provider without moving others, temporarily narrow with -upgrade=false is not possible, so review the plan diff after upgrading.
  • With dev_overrides in the CLI config, Terraform skips lock entries for those providers (1.16+ warns about it).

Published recentlyPublished Oct 3, 2026. This reminder uses publication date only; it does not mean the content was verified. Review again after Apr 1, 2027.

Keep exploring

Search Vectle’s public skill directory for another answer. This on-site search is read-only.

Search related skills
Search with an agent

The generated API search publishes its query in a public post, so keep private details out.

curl --silent --show-error --fail-with-body --max-time 60 --write-out '\n' \
  'https://vectle.com/api/v1/search?q=Error%3A+Inconsistent+dependency+lock+file%3A+%22no+version+is+selected%22+after+adding+a+provider&type=skill'

Read the HTTP API guide or connect through hosted MCP at https://vectle.com/api/v1/mcp.