warrensbox/terraform-switcher

v1.1.0 does not parse tf version constraint correctly

Closed this issue · 5 comments

Hey! I was running the GHA in our repo. which is to download tfswitch. After that, I got an error shows that

warrensbox/terraform-switcher info found version: 1.1.0 for v1.1.0/linux/amd64
warrensbox/terraform-switcher info installed /usr/local/bin/tfswitch
21:39:51.820 INFO Reading version from Terraform module at "tf"  
21:39:51.852 INFO Reading required version from constraint: "= ~>1.3.9"  
21:39:51.852 ERROR No version found matching "= ~>1.3.9"  
21:39:51.852 FATAL Error parsing configuration file: "error parsing constraint: Malformed constraint: = ~>1.3.9"  

However, yesterday ran the older version, did not have this error:

warrensbox/terraform-switcher info found version: 1.0.2 for 1.0.2/linux/amd64
warrensbox/terraform-switcher info installed /usr/local/bin/tfswitch
Reading required version from terraform file
Reading required version from constraint: ~>1.3.9
Matched version: 1.3.10
Creating directory for terraform binary at: /home/runner/.terraform.versions
Downloading to: /home/runner/.terraform.versions
19989918 bytes downloaded
Switched terraform to version "1.3.10" 

Any ideas how to parse the version constraint with v1.1.0?

@AkiraKane Thanks for reporting. We're already aware of this "bug": #403

  • Quick fix: update the value of required_version in your HCL file to have ~> 1.3.9 instead of ~>1.3.9 (put the space between constraint operator and version string)
  • Or temporary downgrade to previous version of tfswitch and wait for the next tfswitch release that will ship the fix 🤷🏻

gotcha, Thanks!

@yermulnik Sorry, one more question, since I am using this command curl -L https://raw.githubusercontent.com/warrensbox/terraform-switcher/release/install.sh | bash to install the latest package in the workflow file, just wondering if there is a way I can still use this command to install the previous version of the package, like 1.0.2?

@AkiraKane Run it like this:

curl -L https://raw.githubusercontent.com/warrensbox/terraform-switcher/release/install.sh | bash -s -- 1.0.2

@yermulnik Awesome. gotta try that. Thanks :)