Ability for the `tf` proxy to switch to terraform even when OpenTofu is present
Is your feature request related to a problem? Please describe.
From what I understand, if ~/.opentofu-version exists, tf will always choose OpenTofu. I switch between the two a lot, and it would be nice if tf always resolves to the last specified tenv <tool> use.
Describe the solution you'd like
The use command switches the tf proxy pointer:
$ tenv tofu use 1.7.0
OpenTofu 1.7.0 already installed
Written 1.7.0 in /Users/ant/.tenv/OpenTofu/version
$ tf version
OpenTofu v1.7.0
on darwin_amd64
+ provider registry.terraform.io/ryanwholey/pihole v0.2.0
$ tenv terraform use 1.5.3
Terraform 1.5.3 already installed
Written 1.5.3 in /Users/ant/.tenv/Terraform/version
$ tf version
Terraform v1.5.3
on darwin_amd64
+ provider registry.terraform.io/ryanwholey/pihole v0.2.0
Describe alternatives you've considered
I am typing out terraform when using terraform instead of the shorthand.
You switch between terraform and opentofu in the same project ?
The resolution order used by tf is here. It does not rely on $TENV_ROOT/<TOOL>/Version written by tenv <tool> use
However, you can use the -w flag to write a .opentofu-version or .terraform-version in the working directory (and rm .opentofu-version to avoid the .terraform-version hiding). As in :
$ tenv tofu use 1.7.0 -w
OpenTofu 1.7.0 already installed
Written 1.7.0 in /home/dvaumoron/go/src/github.com/tofuutils/tenv/.opentofu-version
You switch between terraform and opentofu in the same project ?
No, I have terraform on some work projects and opentofu on personal ones. Sorry I probably should have run those sample commands in a directory where I hadn't run init :)
Ah ok, I was hoping leaving out the -w would just set the home directory file version and that one would be prioritized, but I can adjust to just remember to use the -w on each project.
tf try the resolution order in working directory and does the same on parent directory and so on up to the root.
If there is still no result, it look in user home directory (unless it has already looked).
tf has been designed to rely on a .opentofu-version or a .terraform-version at each project root.
Thank you! I appreciate all the work you guys are putting into thi!