linuxterraformterragrunt

Tools to easily swap terraform versions


I found the tools tfenv and tfswitch to easily and quickly change the terraform and terragrunt version - and I guess the tools work cause people use it, but for some reason they don't chagne the versions on my computer, after I run let's say

$ tfswitch 0.12.25
Downloading https://releases.hashicorp.com/terraform/0.12.25/terraform_0.12.25_darwin_amd64.zip to terraform_0.12.25_darwin_amd64.zip
Downloading ...
18220765 bytes downloaded.
Switched terraform to version "0.12.25"

It seems I correctly switch to version 0.12.25, but after checking it with terraform it didin't change

$ terraform --version
Terraform v0.12.18
+ provider.google v3.29.0
+ provider.random v2.3.0

Your version of Terraform is out of date! The latest version
is 0.12.28. You can update by downloading from https://www.terraform.io/downloads.html

same goes for tfenv tool, anyone met with that problem ? I tried running it with sudo as well, but without success - I see the binaries are being downloaded to config dir of those tools and I even add them to PATH, but they don't overwrite the main terraform or terragrunt binaries that's why I'm left with the old versions, any thoughts ?


Solution

  • I had the same problem in the past, I solved it by removing the reference of Terraform from .bash_profile or .zshrc for zsh.