tfutils/tfenv

Specifying latest does not install the latest version of Terraform.

joeypiccola opened this issue · 3 comments

Was hoping to simply run tfenv use latest to get the latest version of Terraform installed, however it keeps the version at 1.3.1. Sure I can work around this by typing tfenv use 1.3.2, but I am curious what's the expected behavior. FWIW, list-remote lists the latest but it doesn't install it. In my scenario neither .terraform-version or TFENV_TERRAFORM_VERSION are in place. Thanks!

> tfenv list-remote | head -n 1
1.3.2
> tfenv use latest                  
Switching default version to v1.3.1
Default version (when not overridden by .terraform-version or TFENV_TERRAFORM_VERSION) is now: 1.3.1

tfenv use switches to using the latest version that's already installed. If you tfenv install latest, 1.3.3 (now) should be installed, and then tfenv use latest will switch to that.

It seems this is inconsistent with other tfenv use invocations though - e.g. having installed and used 1.3.3 if I now tfenv use 1.3.2 (which I hadn't previously installed) it installs it automatically before switching to it.

I'm trying this:

echo "terraform {
  required_version = \"~> 1.1.0\"
}" > latest_allowed.tf;

> tfenv use latest-allowed
No installed versions of terraform matched 'latest-allowed:^latest-allowed$'. Trying to install a matching version since TFENV_AUTO_INSTALL=true
No versions matching 'latest-allowed' found in remote
Installing a matching version failed

> tfenv
tfenv 3.0.0

Any tips?

@OJFord Good catch on tfenv install, I hadn't used that command before. For my purposes in my CI\CD process if a user supplied latest I will simply run tfenv install latest and then tfenv use latest. Thank you.