asdf-community / asdf-hashicorp

HashiCorp plugin for the asdf version manager
https://github.com/asdf-vm/asdf
MIT License
234 stars 54 forks source link

Fallback to x86 if missing arm64 version #59

Closed voiski closed 1 year ago

voiski commented 1 year ago

We should be ok to run amd64 binaries with rosetta when missing arm64 support, such as old versions of terraform.

$ asdf install
Downloading terraform version 0.14.11 from https://releases.hashicorp.com/terraform/0.14.11/terraform_0.14.11_darwin_arm.zip
M1 was detected, but there is no version available. Downloading the amd64 version to run with rosetta!
Downloading terraform version 0.14.11 from https://releases.hashicorp.com/terraform/0.14.11/terraform_0.14.11_darwin_amd64.zip
Verifying signatures and checksums
gpg: keybox '/var/folders/14/9h539rxx1zv_j1vv1327d5040000gp/T/asdf_terraform_XXXXXX.vR5YVKOf/pubring.kbx' created
gpg: /var/folders/14/9h539rxx1zv_j1vv1327d5040000gp/T/asdf_terraform_XXXXXX.vR5YVKOf/trustdb.gpg: trustdb created
gpg: key 34365D9472D7468F: public key "HashiCorp Security (hashicorp.com/security) <security@hashicorp.com>" imported
gpg: Total number processed: 1
gpg:               imported: 1
gpg: Signature made Tue Apr 19 04:34:35 2022 -03
gpg:                using RSA key 374EC75B485913604A831CC7C820C6D5CD27AB87
gpg: Good signature from "HashiCorp Security (hashicorp.com/security) <security@hashicorp.com>" [unknown]
gpg: WARNING: This key is not certified with a trusted signature!
gpg:          There is no indication that the signature belongs to the owner.
Primary key fingerprint: C874 011F 0AB4 0511 0D02  1055 3436 5D94 72D7 468F
     Subkey fingerprint: 374E C75B 4859 1360 4A83  1CC7 C820 C6D5 CD27 AB87
terraform_0.14.11_darwin_amd64.zip: OK
Cleaning terraform previous binaries
Creating terraform bin directory
Extracting terraform archive
DustinChaloupka commented 1 year ago

There are already options for overriding the arch being used. Does that not handle this problem?

voiski commented 1 year ago

@DustinChaloupka that is true, but this way, we make it transparent to the user. Alternatively, We can print the suggested workaround Install using ASDF_HASHICORP_OVERWRITE_ARCH_FALLBACK=amd64. <- made this way on #60

DustinChaloupka commented 1 year ago

Maybe this is a question of how "dumb" these kinds of install tools should be. IMO, the error that is output about the specific install not being found with the arch/os should be good enough as opposed to adding in cases to handle every edge case that might pop up in the future.

voiski commented 1 year ago

Gotcha! But I still believe a better message could fit here to cover a more general audience.

Suggestion, add the repo link so users, or who will end up supporting them, can follow. I.E.

Error: terraform version 0.14.11 not found
Check documentation for alternatives https://github.com/asdf-community/asdf-hashicorp#usage

To give a little context, we have bootstrap automation for a broader audience. I liked your idea of keeping the code simple, but I prefer to at least link resources to self-serving than getting more support needed in any eventual issue. I'm good either way to implement that suggestion on my automation, as #55 did.

DustinChaloupka commented 1 year ago

I'm fine with it erroring and outputting a link to the documentation, seems reasonable.

voiski commented 1 year ago

Cool, created #61 . Closing this one.