Search code examples
terraform

tfenv not changing the Terraform version


$ tfenv version-name 
1.4.0

$ terraform --version
Terraform v1.2.7
on linux_amd64
+ provider registry.terraform.io/hashicorp/aws v4.48.0
+ provider registry.terraform.io/hashicorp/random v3.4.3
+ provider registry.terraform.io/hashicorp/template v2.2.0

Your version of Terraform is out of date! The latest version
is 1.5.7. You can update...

After I use tfenv the Terraform version does not change. What am I doing wrong? I also tried tenv use v1.4.0, but it does not help, the Terraform version stays the same.

$ tfenv use 1.4.0    
Switching default version to v1.4.0
Default version (when not overridden by .terraform-version or TFENV_TERRAFORM_VERSION) is now: 1.4.0

Solution

  • One way this could happen is by having multiple copies of Terraform installed.

    tfenv expects to be the sole manager of Terraform, with no other copies installed outside of its control. When first using tfenv, you should uninstall any manually installed copies of Terraform, and then reinstall via tfenv.

    If you don't do this, then it is possible that any manually installed Terraform could appear first in your PATH, which will give the appearance of tfenv use having no effect.