tfenv can't see installed terraform versions after upgrade.
Running on MacOS Monterey v12.2.1.
I ran a brew upgrade to upgrade the packages on my machine.
Since then tfenv failed to show any of the Terraform versions I had installed on my machine.
Have they been removed during the upgrade? If so it seems bad that every upgrade essentially destroys my existing setup.
I got the same issue. I also have a lot of 403 error:
$ tfenv install 0.15.0
Installing Terraform v0.15.0
Downloading release tarball from https://releases.hashicorp.com/terraform/0.15.0/terraform_0.15.0_darwin_arm64.zip
curl: (22) The requested URL returned error: 403
Tarball download failed
0.15.0 version doesn't exist for darwin with arm64 processor. The first release of Terraform that provide an arm64 binary is 1.0.2.
You can see it here: https://releases.hashicorp.com/terraform/1.0.2/
For the 0.15.0 version, you may be able to use the arm64 linux binary. Not sure if it works, but it is always better to try
@brandon-welsch That worked for me, thanks!
I'm seeing a similar thing as @Chris-Leeworthy. Recently ran a brew upgrade and just came back to tfenv to do some testing, and now I'm seeing no versions installed.
Even worse for me, when I try to run others commands, it just hangs. Tried tfenv list-remote and tfenv install 1.0.8 so far. tfenv init ran, but didn't seem to do anything. I then tried a quick uninstall / install through brew which didn't seem to fix anything. Guessing some leftover remnant from a previous versions is breaking stuff, but that's a completely random guess at this point. Will update if I get this working, but any help is appreciated.
UPDATE: Well a reboot seems to have fixed the hanging commands issue. But definitely still lost all my versions after the upgrade.
I got the same issue after brew upgrade.
As a workaround, if you need to install an old terraform version, use export TFENV_ARCH=amd64
It seems like this is two slightly different and related issues. The combination makes for a nasty breaking change for anyone using tfenv to run older versions of terraform on Darwin ARM64.
- #280 does not handle versions prior to
1.0.2, so tfenv2.2.3is now unusable for them.
A few things could be done to address this: adding a compatibility mode that installs amd64 instead on older versions, pulling amd64 instead of arm64 if you get a 403 (idk why they're doing that instead of 404), Hashicorp uploading arm64 binaries for older versions, or
@requix's suggestion above helps address this on the install side. And with GODEBUG=asyncpreemptoff=1 (credit), amd64 versions of terraform mostly work under Rosetta.
- old copies of terraform get deleted by the upgrade (the original post)
It looks like homebrew is automatically cleaning up old versions under the cellar path. Unfortunately, that deletes the old terraform binaries. This wouldn't be a huge deal if it were easy to re-install them, but with the breaking change above, it's unfortunate.
For what it's worth I'm using tfenv on an Intel based Mac.
Have they been removed during the upgrade?
I'm not 100% sure but I think they did get removed. In my case terraform gets installed into /home/linuxbrew/.linuxbrew/Cellar/tfenv/2.2.3/versions, and I don't see any other versions.
Have they been removed during the upgrade?
I'm not 100% sure but I think they did get removed. In my case terraform gets installed into
/home/linuxbrew/.linuxbrew/Cellar/tfenv/2.2.3/versions, and I don't see any other versions.
You can set the environment variable HOMEBREW_NO_INSTALL_CLEANUP=1 to prevent homebrew from automatically deleting old formula data when upgrading, or put the specific formulae in HOMEBREW_NO_CLEANUP_FORMULAE. If you use bash export HOMEBREW_NO_CLEANUP_FORMULAE=tfenv in ~/.bash_profile should do the trick.
Housekeeping for Homebrew is a decent write-up on brew cleanup and related commands
Here are the docs from homebrew source
HOMEBREW_NO_INSTALL_CLEANUP: {
description: "If set, `brew install`, `brew upgrade` and `brew reinstall` will never automatically " \
"cleanup installed/upgraded/reinstalled formulae or all formulae every " \
"`HOMEBREW_CLEANUP_PERIODIC_FULL_DAYS` days. Alternatively, HOMEBREW_NO_CLEANUP_FORMULAE " \
"allows specifying specific formulae to not clean up.",
boolean: true,
I don't know if tfenv could or should set this to true for itself?
This issue seems to contain a number of unrelated concerns.
The issue as reported is a Homebrew packaging issue. I'm afraid the Homebrew packaging is done independently by a third party; I'm not even sure how to report issues with it.
One other workaround is to run your tfenv command via Rosetta2. I had to migrate to an M1 MacBook and some stuff that used to work on my older MacBook needed to use Rosetta2. If you setup a separate terminal window where you're running it against Rosetta2 and run the same Terraform commands like tfenv use 0.11.15, this will work in a Terminal window that has been configured to use Rosetta2.