terraform-switcher: Stopped working inside terraform project

❯ tfswitch
Reading required version from terraform file
Cannot get list from mirror: https://releases.hashicorp.com/terraform
Reading required version from constraint: ~> 1.1, >= 1.1.2
Version does not exist or invalid terraform version format.
 Format should be #.#.# or #.#.#-@# where # are numbers and @ are word characters.
 For example, 0.11.7 and 0.11.9-beta1 are valid versions
error parsing constraint: ~> 1.1, >= 1.1.2
No version found to match constraint. Follow the README.md instructions for setup. https://github.com/warrensbox/terraform-switcher/blob/master/README.md

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Reactions: 80
  • Comments: 49 (5 by maintainers)

Commits related to this issue

Most upvoted comments

Fixed with release 0.13.1221

workaround

In first terminal

mkdir release
curl  'https://releases.hashicorp.com/terraform' | sed  's#">t#/">t#' > release/index.html
python3 -m http.server

Then in another terminal

$ tfswitch -m http://127.0.0.1:8000/release

Team anyone working on fix ?

Hi, we have the same error, a lot of our jobs that are not working , have you planned a fix or a workaround ? Thanks

🤔 I wonder if, in the interest of solving the problem quickly, it might not be better to use https://github.com/warrensbox/terraform-switcher/pull/225 to fix this issue - and to open a separate issue for using the new API.

I think a lot of people are using tfswitch in their pipelines, and eventually they don’t want to use a local mirror (nice workaround by the way, thanks for it @aderuelle) and thus desperately waiting for a working tfswitch version to be released.

Just a thought - ymmv. 💭

Same problem here (;

I have a working hack for this. testing it locally then I’ll figure out how to make a PR.

FYI: https://www.hashicorp.com/blog/announcing-the-hashicorp-releases-api

I would love this to become a new source of truth, but it provides quite limited subset of versions at the moment:

$ curl -sS https://api.releases.hashicorp.com/v1/releases/terraform/ | jq -r '.[].version' | sort
1.1.4
1.1.5
1.1.6
1.1.7
1.1.8
1.1.9
1.2.0-alpha-20220328
1.2.0-alpha20220413
1.2.0-beta1
1.2.0-rc1

it shows them all, the default is only 10. Should be relatively easy to implement an interface to use this instead of the current url. Working on a patch at the moment

https://releases.hashicorp.com/docs/api/v1/#operation/getReleasesV1

FYI: https://www.hashicorp.com/blog/announcing-the-hashicorp-releases-api

I would love this to become a new source of truth, but it provides quite limited subset of versions at the moment:

$ curl -sS https://api.releases.hashicorp.com/v1/releases/terraform/ | jq -r '.[].version' | sort
1.1.4
1.1.5
1.1.6
1.1.7
1.1.8
1.1.9
1.2.0-alpha-20220328
1.2.0-alpha20220413
1.2.0-beta1
1.2.0-rc1

Piggy-backing off this because it had a lot of activity. Anyone interested in assisting the tfswitch project as a collaborator/maintainer? I’ll let @warrensbox add additional info but he’s mostly looking for folks to help review PR’s. I’ve already offered my help moving forward but the more the merrier.

I wouldn’t mind helping out @Jukie / @warrensbox

hmm, so from multiple attempts one time it worked fine, I guess this local problem on my macos, thanks for a response.

@aderuelle I couldn’t find a github repo for it so I opened one here in the terraform repo and also sent them an email.

workaround

In first terminal

mkdir release
curl  'https://releases.hashicorp.com/terraform' | sed  's#">t#/">t#' > release/index.html
python3 -m http.server

Then in another terminal

$ tfswitch -m http://127.0.0.1:8000/release

Works only, when the version is present on the machine!

::ffff:127.0.0.1 - - [10/May/2022 11:08:01] code 404, message File not found
::ffff:127.0.0.1 - - [10/May/2022 11:08:01] "GET /release/1.1.9/terraform_1.1.9_darwin_amd64.zip HTTP/1.1" 404 -
[Error] : Unable to download from http://127.0.0.1:8000/release/1.1.9/terraform_1.1.9_darwin_amd64.zip

As I actually need to download it (inside CI)… decided to go with good old curl

Hi everyone, I think that I have a similar problem. I’m trying to switch some specific terraform versions, however I got the following error: The provided terraform version does not exist. Try tfswitch -l to see all available versions.

I tried with two different versions of tfswitch. Initially: `➜ ~ tfswitch -v

Version: 0.12.1092`

And then I have upgraded to:

`➜ ~ tfswitch -v

Version: 0.13.1218`

image

semver = \/(\d+\.\d+\.\d+)\/

<a href="/terraform/0.5.0">terraform_0.5.0</a>

Seems like the links in the release page are now missing the trailing slash in href=

@andrewsavino1 tried at least 5 times, both on ci and locally and it didn’t work, so created the ticket. Now it works on both platforms

@DP19 did you manage to get the after parameter right ? I can’t get past the 1.0.10 release here …

Hi, we have the same error, a lot of our jobs that are not working , have you planned a fix or a workaround ? Thanks

Look like pull request is in place : pull request LINK