potatopotato
potatopotato

Reputation: 1174

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 ?

Upvotes: 2

Views: 3865

Answers (4)

kvendingoldo
kvendingoldo

Reputation: 420

Btw. you can also try https://github.com/tofuutils/tenv. It's a modern replacement for tfenv

Upvotes: 0

vladelleus
vladelleus

Reputation: 11

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

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

Upvotes: 1

Maverick32
Maverick32

Reputation: 15

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.

Upvotes: 0

Ribeiro
Ribeiro

Reputation: 1071

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

Upvotes: 2

Related Questions