tfutils / tfenv

Terraform version manager
MIT License
4.51k stars 454 forks source link

No arm64 builds for terraform < 1.0.2 #384

Open alex-shafer-1002 opened 1 year ago

alex-shafer-1002 commented 1 year ago

Installs for terraform version < 1.0.2 fail on my M1 mac unless TFENV_ARCH=amd64 is specified.

% tfenv install 1.0.2
Installing Terraform v1.0.2
Downloading release tarball from https://releases.hashicorp.com/terraform/1.0.2/terraform_1.0.2_darwin_arm64.zip
###################################################################################################################################### 100.0%
Downloading SHA hash file from https://releases.hashicorp.com/terraform/1.0.2/terraform_1.0.2_SHA256SUMS
Not instructed to use Local PGP (/opt/homebrew/Cellar/tfenv/3.0.0/use-{gpgv,gnupg}) & No keybase install found, skipping OpenPGP signature verification
Archive:  /var/folders/18/dd_564kj0mx9njswprq1tg6m0000gn/T/tfenv_download.XXXXXX.25rviT3E/terraform_1.0.2_darwin_arm64.zip
  inflating: /opt/homebrew/Cellar/tfenv/3.0.0/versions/1.0.2/terraform  
Installation of terraform v1.0.2 successful. To make this your default version, run 'tfenv use 1.0.2'
% tfenv install 1.0.1
Installing Terraform v1.0.1
Downloading release tarball from https://releases.hashicorp.com/terraform/1.0.1/terraform_1.0.1_darwin_arm64.zip
curl: (22) The requested URL returned error: 404                                                                                            

Tarball download failed
% TFENV_ARCH=amd64 tfenv install 1.0.1
Installing Terraform v1.0.1
Downloading release tarball from https://releases.hashicorp.com/terraform/1.0.1/terraform_1.0.1_darwin_amd64.zip
###################################################################################################################################### 100.0%
Downloading SHA hash file from https://releases.hashicorp.com/terraform/1.0.1/terraform_1.0.1_SHA256SUMS
Not instructed to use Local PGP (/opt/homebrew/Cellar/tfenv/3.0.0/use-{gpgv,gnupg}) & No keybase install found, skipping OpenPGP signature verification
Archive:  /var/folders/18/dd_564kj0mx9njswprq1tg6m0000gn/T/tfenv_download.XXXXXX.Yxrr9RXM/terraform_1.0.1_darwin_amd64.zip
  inflating: /opt/homebrew/Cellar/tfenv/3.0.0/versions/1.0.1/terraform  
Installation of terraform v1.0.1 successful. To make this your default version, run 'tfenv use 1.0.1'

Not shown: fishing for the lowest version with arm64 support

reegnz commented 1 year ago

That's because hashicorp didn't publish any binaries for M1 macs before 1.0.2. The same problem applies to using older provider versions.

If you need to use earlier terraform (or provider ) versions all the time, that hashicorp didn't build a darwin_arm64 binary for, I'd suggest you put export TFENV_ARCH=amd64 into your bashrc/zshrc and just keep using amd64 binaries for all of your terraform. Have rosetta2 handle it for you. (This is what I'm doing).

alex-shafer-1002 commented 1 year ago

Hello,

I agree and have done so already, however I see we have some logic that attempts to handle this and appears to be faulty somehow given that this fails: https://github.com/tfutils/tfenv/blob/master/libexec/tfenv-install#L125

reegnz commented 1 year ago

Yeah, I poked around that bash logic last week and indeed it seems to be flaky.

iomarcovalente commented 1 year ago

it would be handy for this to be documented here

even just a one-liner quick mention that

Installs for terraform version < 1.0.2 fail on Arm based mac unless TFENV_ARCH=amd64 is specified as multi-arch binaries aren't published before that version

alex-shafer-1002 commented 1 year ago

@iomarcovalente there is logic in place that does this automatically, it's just not been released to homebrew. It seems we're way behind on releases, merging, etc. I'm getting concerned about the maintenance of this project myself.

reegnz commented 1 year ago

it's just not been released to homebrew

It just not been released period. It's not homebrew-s fault that there's no tfenv release of that feature. If tfenv has a release of that feature, I'm 100% sure it shows up in homebrew within a day or two.

BTW you can still install with homebrew from HEAD to have that feature: brew install --HEAD tfenv.