Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No compatible version found when loading required_version from .tf file #163

Closed
ThibaultNocchi opened this issue Jun 11, 2024 · 3 comments
Closed
Labels
bug Something isn't working

Comments

@ThibaultNocchi
Copy link

Describe the bug
Since tenv v2, I can't fetch the TF CLI when detecting the required_version from a .tf file. I get the Error: no compatible version found error.

It worked in v1 and I can use tenv tf install 1.7.0 without problem in v2.

To Reproduce
Steps to reproduce the behavior:

  1. Write a basic providers.tf
# Configure the Terraform backend for remote state
terraform {
  required_version = "~> 1.7.0"
}
  1. Run tenv tf detect -v
  2. Fails

Expected behavior
It should download the correct version like when using tenv tf install.

Environment (please complete the following information):

  • OS: Linux
  • tofuenv version 2.0.3

Additional context

root@818c4335f354:/# cat providers.tf
# Configure the Terraform backend for remote state
terraform {
  required_version = "~> 1.7.0"
}


root@818c4335f354:/# tenv --version
tenv version v2.0.3


root@818c4335f354:/# tenv tf detect -v
2024-06-11T12:53:52.586Z [DEBUG] tenv: Failed to read file: error="open .terraform-version: no such file or directory"
2024-06-11T12:53:52.586Z [DEBUG] tenv: Failed to read file: error="open .tfswitchrc: no such file or directory"
2024-06-11T12:53:52.586Z [DEBUG] tenv: Failed to read terragrunt file: error="open terragrunt.hcl: no such file or directory"
2024-06-11T12:53:52.586Z [DEBUG] tenv: Failed to read terragrunt file: error="open terragrunt.hcl.json: no such file or directory"
2024-06-11T12:53:52.586Z [DEBUG] tenv: Failed to read file: error="open /root/.terraform-version: no such file or directory"
2024-06-11T12:53:52.586Z [DEBUG] tenv: Failed to read file: error="open /root/.tfswitchrc: no such file or directory"
2024-06-11T12:53:52.586Z [DEBUG] tenv: Failed to read terragrunt file: error="open /root/terragrunt.hcl: no such file or directory"
2024-06-11T12:53:52.586Z [DEBUG] tenv: Failed to read terragrunt file: error="open /root/terragrunt.hcl.json: no such file or directory"
2024-06-11T12:53:52.586Z [DEBUG] tenv: Failed to read file: error="open /root/.tenv/Terraform/version: no such file or directory"
No version files found for Terraform, fallback to latest-allowed strategy
Scan project to find .tf files
2024-06-11T12:53:52.586Z [DEBUG] tenv: Read: filePaths=["providers.tf"]
2024-06-11T12:53:52.587Z [DEBUG] tenv: Failed to read file: error="open /root/.tenv/Terraform/constraint: no such file or directory"
2024-06-11T12:53:52.587Z [DEBUG] tenv: Find: constraints=["~> 1.7.0"]
Error: no compatible version found
Usage:
  tenv tf detect [flags]

Flags:
  -a, --arch string          specify arch for binaries downloading (default "amd64")
  -f, --force-remote         force search on versions available at TFENV_REMOTE url
  -h, --help                 help for detect
  -k, --key-file string      local path to PGP public key file (replace check against remote one)
  -n, --no-install           disable installation of missing version (default true)
  -c, --remote-conf string   path to remote configuration file (advanced settings)
  -u, --remote-url string    remote url to install from

Global Flags:
  -q, --quiet              no unnecessary output (and no log)
  -r, --root-path string   local path to install versions of OpenTofu, Terraform, Terragrunt, and Atmos (default "/root/.tenv")
  -v, --verbose            verbose output (and set log level to Trace)

no compatible version found
@kvendingoldo kvendingoldo added the bug Something isn't working label Jun 11, 2024
@kvendingoldo
Copy link
Collaborator

can you try to do the following, please?

export TENV_AUTO_INSTALL=true
tenv tf detect -v

By default, we disabled autoinstall in V2 via detect command. I think that we can add flag to the command to install tools automatically, like tenv tf detect --install

@ThibaultNocchi
Copy link
Author

Indeed it works way better, thank you! I missed it in the 2.0 changes!
Maybe the error message reworded, but thank you! Have a nice day!

@ThibaultNocchi ThibaultNocchi closed this as not planned Won't fix, can't repro, duplicate, stale Jun 12, 2024
@kvendingoldo
Copy link
Collaborator

@ThibaultNocchi one more question for you as for user. Do you think that it's more or less expected behavior? We have debated about it some time ago (https://github.com/orgs/tofuutils/discussions/4) and still gathering user opinions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants