Skip to content

Does not work with terraform -chdir or modules #246

@OJFord

Description

@OJFord

Describe the bug
It seems tenv only scans terraform files in the current directory.

If all such files are in a tf subdirectory say, with a tf/.terraform-version of min-required and tf/providers.tf having terraform { required_version = "~> 1.5" }, then:

$terraform -chdir=tf version
Resolved version from .terraform-version : min-required
Scan project to find IAC files
No Terraform version requirement found in project files, fallback to latest strategy
[...]

(note also that that requires .terraform-version in $PWD - it won't find that from the -chdir either)

Even without -chdir, if there's additionally a tf/module/providers.tf with a terraform { required_version = "~> 1.9" } say, then:

$cd tf && terraform version
Resolved version from [..]/.terraform-version : min-required
Scan project to find IAC files
No compatible version found locally, search a remote one...
Fetching all releases information from https://releases.hashicorp.com/terraform/index.json
Found compatible version remotely : 1.5.0
Installing Terraform 1.5.0

ignoring the 1.9 requirement.

To Reproduce
Described above

Expected behavior
1.9.0 installed in both cases, with or without -chdir, 1.5.0 is not compatible.

Screenshots
N/A

Environment (please complete the following information):

  • OS: [e.g. iOS] macOS (iOS?!)
  • tofuenv tenv version [e.g. 0.8.0] 3.1.0

Additional context
N/A

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingquestionFurther information is requested

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions