2

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 ?

potatopotato
  • 1,024
  • 2
  • 16
  • 38
  • 3
    Sorry, but StackOverflow is dedicated to helping solve programming code problems. If related to a production-level problem Your Q **may be** more appropriate for [sf] , but read their help section regarding on-topic questions . AND please read [Help On-topic](https://stackoverflow.com/Help/On-topic) and [Help How-to-ask](https://stackoverflow.com/Help/How-to-ask) before posting more Qs here. Good luck. – shellter Jul 18 '20 at 14:12
  • 1
    Also, be sure to hover on the `teraform` tag at the bottom of your Q and read that information. – shellter Jul 18 '20 at 14:13

3 Answers3

2

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

Ribeiro
  • 851
  • 6
  • 7
0

I'm having the exact same problem whilst using tfswitch

tfswitch 0.13.0
Installing terraform at /home/bin
Switched terraform to version "0.13.0"

terraform -v
Terraform v0.12.26

Terraform doesn't actually switch the versions and remains at v0.12.26

The answer provided on this post for removing the tf references located in .bash_profile doesn't appear to be working for me as the only reference to $PATH is the binaries for tfswitch for /home/bin which is required for it to work.

Maverick32
  • 15
  • 7
0

I have encountered with such a problem and fixed it by adding to ~/.zshrc or add to your ~/.bashrc :

export PATH="$HOME/bin:$PATH"