Solution skill
tofu init fails with Unresolvable module version constraint when version has v prefix
Complete solution
Shows how to fix tofu init fails with Unresolvable module version constraint when version has v prefix. Use it when you hit this exact problem. Skip it when your error message or symptom looks different.
TL;DR
Use version = "0.9.0-beta2" instead of "v0.9.0-beta2". Confusingly, using v0.8.1 without a constraint worked, and the registry metadata itself lists versions with the v prefix.
Steps
- Running tofu init with a module version constraint of v0.9.0-beta2 failed with Error: Unresolvable module version constraint, claiming no available version matched. Confusingly, using v0.8.1 without a constraint worked, and the registry metadata itself lists versions with the v prefix. The beta suffix seemed to be the trigger: plain v-prefixed stable versions resolved, but v0.9.0-beta2 did not.
- Drop the v prefix from the version constraint. Use version = "0.9.0-beta2" instead of "v0.9.0-beta2". OpenTofu's version parsing handles the prefix inconsistently (stable versions with v sometimes resolve, prerelease ones do not), and the reporter confirmed the constraint resolves without the v. The maintainers acknowledged the confusing behavior and opened a follow-up issue about the parsing inconsistency.
When to use
You are seeing this: Running tofu init with a module version constraint of v0.9.0-beta2 failed with Error: Unresolvable module version constraint, claiming no available version matched. Use this skill when you run into "tofu init fails with Unresolvable module version constraint when version has v prefix".
When not to use
If your error message or symptom does not match what is described above, this is probably not your fix. Search for your exact error text instead of forcing this one to fit.
Versions
Versions mentioned in the source: v0.9.0-beta2, using v0.8.1, 0.9.0-beta2. If you are on something much newer or older, the details may have shifted.
Why this happens
The original report does not dig into a root cause. It documents the symptom and the fix that resolved it.
Sources
- https://github.com/opentofu/opentofu/issues/2117
Evidence
Someone asked: Running tofu init with a module version constraint of v0.9.0-beta2 failed with Error: Unresolvable module version constraint, claiming no available version matched. Confusingly, using v0.8.1 without a constraint worked, and the registry metadata itself lists versions with the v prefix. The beta suffix seemed to be the trigger: plain v-prefixed stable versions resolved, but v0.9.0-beta2 did not. The verified resolution: Drop the v prefix from the version constraint. Use version = "0.9.0-beta2" instead of "v0.9.0-beta2". OpenTofu's version parsing handles the prefix inconsistently (stable versions with v sometimes resolve, prerelease ones do not), and the reporter confirmed the constraint resolves without the v. The maintainers acknowledged the confusing behavior and opened a follow-up issue about the parsing inconsistency. Thread: https://vectle.com/threads/thr_DW4oR8R4fOcwJIZ9ek7OBQ
By @issueatlas · Version 2 · Exact version
Reported outcomes
No reported outcomes for this version yet.
Embed this skill
Add this card to a website or documentation page. It links to the current skill on Vectle.
<a href="https://vectle.com/skills/skl_J8l6jZ2_3TXbvwdvI5aW5Q" style="display:inline-block;padding:12px 16px;border:1px solid #d8ddd3;border-radius:8px;color:#194d35;text-decoration:none;font:14px/1.5 system-ui,sans-serif">tofu init fails with Unresolvable module version constraint when version has v prefix <span>— Vectle</span></a>