Yleisradio / chtf

Terraform version switcher with automatic install
MIT License
21 stars 4 forks source link

undefined method `using' for nil:NilClass #12

Closed spanktar closed 7 months ago

spanktar commented 2 years ago

chtf 0.14.11 chtf: Terraform version 0.14.11 not found chtf: Do you want to install it? [yN] y chtf: Installing Terraform version 0.14.11 Error: Download failed on Cask 'terraform-0.14.11' with message: undefined method `using' for nil:NilClass

brew upgrade chtf Warning: yleisradio/terraforms/chtf 2.1.1 already installed

❯ chtf 1.0.7 chtf: Terraform version 1.0.7 not found chtf: Do you want to install it? [yN] y chtf: Installing Terraform version 1.0.7 ==> Downloading https://releases.hashicorp.com/terraform/1.0.7/terraform_1.0.7_darwin_arm64.zip ######################################################################## 100.0% ==> Installing Cask terraform-1.0.7 🍺 terraform-1.0.7 was successfully installed!

OSX Monterey 12.1 Apple Silicon

tmatilai commented 2 years ago

Hi,

Thanks for the report!

Apple Silicon

Ah, right. There are no arm64 builds of Terraform before v1.0.2.

In the Cask template we have a switch for the architecture, and for older Casks there is no match. Seems that the depends_on :arch [:x86_64] doesn't do much, and the error message is really bad. 🙁

I guess the best solution would be to default to amd64 if there is no matching arch. Requires a bit of changes to the script and template. I'll hope to remember to take a closer look over the weekend.


In the meanwhile, as a workaround you can download and extract the package manually. For example:

curl https://releases.hashicorp.com/terraform/0.14.11/terraform_0.14.11_darwin_amd64.zip > tf.zip
# Then you should verify the checksum of the downloaded package. Left as an exercise. ;) 
mkdir -p /opt/homebrew/Caskroom/terraform-0.14.11/0.14.11
unzip -d /opt/homebrew/Caskroom/terraform-0.14.11/0.14.11 tf.zip
rm tf.zip

chtf 0.14.11
spanktar commented 2 years ago

Thanks, I realized the problem (with Apple silicon) after I filed this, but thought you might like to know and work on improving the error messaging, or try to handle the situation better.

Thank you!

tmatilai commented 7 months ago

This should be finally fixed now with chtf v2.2.0 and later. Although I hope no-one needs the old intel-only versions any more. 🙄