tgswitch icon indicating copy to clipboard operation
tgswitch copied to clipboard

Tgswitch sometimes fails with a 404 from GitHub

Open crablab opened this issue 1 year ago • 3 comments

Splitting this out as it should have been a separate issue.

Originally posted by @maxfriedrich in https://github.com/warrensbox/tgswitch/issues/117#issuecomment-1177576820


Hi, I have a simple setup that results in a 404 page from GitHub pages being downloaded and stored in ~/.terragrunt.versions:

terragrunt.hcl:

terragrunt_version_constraint = "0.35.20"
$ rm -r ~/.terragrunt.versions && tgswitch
Terragrunt file found: /Users/max.friedrich/tgswitch-test/terragrunt.hcl
Reading required version from constraint: 0.35.20
Matched version: 0.35.20
2022/07/07 14:56:54 Creating directory for terragrunt: /Users/max.friedrich/.terragrunt.versions/
Downloading https://warrensbox.github.io/terragunt-versions-list/index.json/v0.35.20/terragrunt_darwin_amd64 to terragrunt_darwin_amd64
Downloading ...
9339 bytes downloaded.
Switched terragrunt to version "0.35.20"

$ head ~/.terragrunt.versions/terragrunt_0.35.20
<!DOCTYPE html>
<html>
  <head>
    <meta http-equiv="Content-type" content="text/html; charset=utf-8">
    <meta http-equiv="Content-Security-Policy" content="default-src 'none'; style-src 'unsafe-inline'; img-src data:; connect-src 'self'">
    <title>Page not found &middot; GitHub Pages</title>
    <style type="text/css" media="screen">
      body {
        background-color: #f1f1f1;
        margin: 0;

If the specified version was already downloaded before with tgswitch "0.35.20" everything works as expected.


Opening a new issue as we similar issue with this, periodically, in our pipelines.

crablab avatar Nov 02 '22 14:11 crablab

My 2 cents on this: it's probably rate limiting from GitHub, which is why we see it happening in our automated pipeline.

I think the bug here is that Tgswitch doesn't return a non-zero exit code when it fails to download a Tg binary.

Ideally we would be able to check that Tgswitch had failed to download and then add logic around that to retry with backoff. Even better if Tgswitch did this automatically (although I think that is a want, rather than a need)

crablab avatar Nov 02 '22 14:11 crablab

Seems related to https://github.com/warrensbox/tgswitch/issues/132

asvinours avatar Dec 13 '22 14:12 asvinours

Just a thought, this might be happening on ARM / Apple Silicon when attempting to install an older release of terragrunt with no ARM binary. I ran into this problem with tfenv & the solution was to specify a variable in the command line like TFENV_ARCH=amd64 tfenv install 0.14.5. This installed the x64 version which runs fine via Rosetta2.

mrbfrank avatar Jan 26 '23 00:01 mrbfrank