Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to get terraform switcher install working via Github actions #525

Closed
janani2019 opened this issue Dec 9, 2024 · 16 comments
Closed
Assignees

Comments

@janani2019
Copy link

janani2019 commented Dec 9, 2024

Is your feature request related to a problem? Please describe.

I am trying to install terraform switcher into an Ubuntu container via GitHub actions:

- name: install tfswitch
      run: |
            echo "Installing tfswitch locally"
            wget https://raw.githubusercontent.com/warrensbox/terraform-switcher/release/install.sh #Get the installer on to your machine
            chmod 755 install.sh            #Make installer executable
            ./install.sh -b `pwd`/.bin      #Install tfswitch in a location you have permission
            CUSTOMBIN=`pwd`/.bin            #set custom bin path
            export PATH=$PATH:$CUSTOMBIN    #Add custom bin path to PATH environment
            tfswitch -b $CUSTOMBIN/terraform 0.11.7
            terraform -v                    #testing version

I get this error -

##[debug]Evaluating condition for step: 'install tfswitch'
##[debug]Evaluating: success()
##[debug]Evaluating success:
##[debug]=> true
##[debug]Result: true
##[debug]Starting: install tfswitch
##[debug]Loading inputs
##[debug]Loading env
Run echo "Installing tfswitch locally"
##[debug]Overwrite 'working-directory' base on job defaults.
##[debug]sh -e /__w/_temp/6b5879f4-c87[2](https://github.com/DigitalTitleGroup/seq-infra-tf-federated-iam/actions/runs/12242560574/job/34150152134#step:8:2)-4feb-8c8a-e0cbb8bc80c6.sh
Installing tfswitch locally
--2024-12-09 11:11:46--  https://raw.githubusercontent.com/warrensbox/terraform-switcher/release/install.sh
Resolving raw.githubusercontent.com (raw.githubusercontent.com)... 185.199.108.1[3](https://github.com/DigitalTitleGroup/seq-infra-tf-federated-iam/actions/runs/12242560574/job/34150152134#step:8:3)3, 185.199.111.133, 185.199.110.133, ...
Connecting to raw.githubusercontent.com (raw.githubusercontent.com)|185.199.108.133|:[4](https://github.com/DigitalTitleGroup/seq-infra-tf-federated-iam/actions/runs/12242560574/job/34150152134#step:8:4)43... connected.
HTTP request sent, awaiting response... 200 OK
Length: 9272 (9.1K) [text/plain]
Saving to: ‘install.sh’
     0K .........                                             100% 1.11M=0.008s
2024-12-09 11:11:4[7](https://github.com/DigitalTitleGroup/seq-infra-tf-federated-iam/actions/runs/12242560574/job/34150152134#step:8:7) (1.11 MB/s) - ‘install.sh’ saved [9272/9272]
warrensbox/terraform-switcher info checking GitHub for tag 'v1.2.4'
warrensbox/terraform-switcher crit unable to find 'v1.2.4' - use 'latest' or see https://github.com/warrensbox/terraform-switcher/releases for details
Error: Process completed with exit code 1.
##[debug]Finishing: install tfswitch

Describe the solution you'd like

I'd expect it to install tfswitch seamlessly onto the container. Any assistance with this issue would be appreciated!

@janani2019 janani2019 added the enhancement Refactor existing code for better performance and quality label Dec 9, 2024
@yermulnik yermulnik removed the enhancement Refactor existing code for better performance and quality label Dec 9, 2024
@yermulnik
Copy link
Collaborator

wget https://raw.githubusercontent.com/warrensbox/terraform-switcher/release/install.sh #Get the installer on to your machine

It's been a while now since we switched from release to master branch for most up-to-date code: https://github.com/warrensbox/terraform-switcher#linux — please use this link to download installation script: https://raw.githubusercontent.com/warrensbox/terraform-switcher/master/install.sh

@yermulnik yermulnik closed this as not planned Won't fix, can't repro, duplicate, stale Dec 9, 2024
@janani2019
Copy link
Author

janani2019 commented Dec 9, 2024

@yermulnik Thank you for your response. I still see the same error after updating. Please assist :

GitHub Workflow step:

 - name: install tfswitch
      run: |
            echo "Installing tfswitch locally"
            wget https://raw.githubusercontent.com/warrensbox/terraform-switcher/master/install.sh
             #Get the installer on to your machine
            chmod 755 install.sh            #Make installer executable
            ./install.sh -b `pwd`/.bin      #Install tfswitch in a location you have permission
            CUSTOMBIN=`pwd`/.bin            #set custom bin path
            export PATH=$PATH:$CUSTOMBIN    #Add custom bin path to PATH environment
            tfswitch -b $CUSTOMBIN/terraform 0.11.7
            terraform -v                    #testing version

Error:

##[debug]Evaluating condition for step: 'install tfswitch'
##[debug]Evaluating: success()
##[debug]Evaluating success:
##[debug]=> true
##[debug]Result: true
##[debug]Starting: install tfswitch
##[debug]Loading inputs
##[debug]Loading env
Run echo "Installing tfswitch locally"
##[debug]Overwrite 'working-directory' base on job defaults.
##[debug]sh -e /__w/_temp/dc8fc[2](https://github.com/DigitalTitleGroup/seq-infra-tf-federated-iam/actions/runs/12245020843/job/34158005993#step:8:2)80-ec07-40de-bfe7-89052e28155e.sh
--2024-12-09 14:00:12--  https://raw.githubusercontent.com/warrensbox/terraform-switcher/master/install.sh
Installing tfswitch locally
Resolving raw.githubusercontent.com (raw.githubusercontent.com)... 185.199.110.1[3](https://github.com/DigitalTitleGroup/seq-infra-tf-federated-iam/actions/runs/12245020843/job/34158005993#step:8:3)3, 185.199.109.133, 185.199.111.133, ...
Connecting to raw.githubusercontent.com (raw.githubusercontent.com)|185.199.110.133|:[4](https://github.com/DigitalTitleGroup/seq-infra-tf-federated-iam/actions/runs/12245020843/job/34158005993#step:8:4)43... connected.
HTTP request sent, awaiting response... 200 OK
Length: 94[6](https://github.com/DigitalTitleGroup/seq-infra-tf-federated-iam/actions/runs/12245020843/job/34158005993#step:8:6)3 (9.2K) [text/plain]
Saving to: ‘install.sh’
     0K .........                                             100% 6.33M=0.001s
2024-12-0[9](https://github.com/DigitalTitleGroup/seq-infra-tf-federated-iam/actions/runs/12245020843/job/34158005993#step:8:9) 14:00:14 (6.33 MB/s) - ‘install.sh’ saved [9463/9463]
warrensbox/terraform-switcher info checking GitHub for tag 'latest'
warrensbox/terraform-switcher crit unable to find 'latest' - use 'latest' or see https://github.com/warrensbox/terraform-switcher/releases for details
Error: Process completed with exit code 1.
##[debug]Finishing: install tfswitch

@yermulnik
Copy link
Collaborator

@janani2019 Please use triple backticks for code blocks.

I can't reproduce 🤔

> ls -la
total 44
drwxr-xr-x  2 giermulnik giermulnik  4096 Dec 10 00:46 .
drwxr-xr-x 12 giermulnik giermulnik 36864 Dec 10 00:46 ..

> wget https://raw.githubusercontent.com/warrensbox/terraform-switcher/master/install.sh
--2024-12-10 00:49:09--  https://raw.githubusercontent.com/warrensbox/terraform-switcher/master/install.sh
Resolving raw.githubusercontent.com (raw.githubusercontent.com)... 185.199.108.133, 185.199.110.133, 185.199.109.133, ...
Connecting to raw.githubusercontent.com (raw.githubusercontent.com)|185.199.108.133|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 9463 (9,2K) [text/plain]
Saving to: ‘install.sh’

install.sh                    100%[==============================================>]   9,24K  --.-KB/s    in 0,001s

2024-12-10 00:49:09 (10,2 MB/s) - ‘install.sh’ saved [9463/9463]

> chmod 755 install.sh
> ./install.sh -b `pwd`/.bin
warrensbox/terraform-switcher info checking GitHub for tag 'latest'
warrensbox/terraform-switcher info found version: v1.2.4 for latest/linux/amd64
warrensbox/terraform-switcher info installed /home/giermulnik/tmp/qwe/.bin/tfswitch

> ls -la .bin/
total 11120
drwxr-xr-x 2 giermulnik giermulnik     4096 Dec 10 00:49 .
drwxr-xr-x 3 giermulnik giermulnik     4096 Dec 10 00:49 ..
-rwxr-xr-x 1 giermulnik giermulnik 11374744 Dec 10 00:49 tfswitch

It works w/o issues even with script version from release branch.

Can you please replace ./install.sh -b pwd/.bin with sh -x ./install.sh -b pwd/.bin and attach full output

@MatthewJohn
Copy link
Collaborator

MatthewJohn commented Dec 9, 2024

It's very odd, it seems to be getting to:

tag_to_version() {
  test -z "${TAG}" && TAG="latest"
  log_info "checking GitHub for tag '${TAG}'"
  REALTAG=$(github_release "$OWNER/$REPO" "${TAG}") && true
  if test -z "$REALTAG"; then
    log_crit "unable to find '${TAG}' - use 'latest' or see https://github.com/${PREFIX}/releases for details"
    exit 1
  fi
}

Unforunately, we can't see what github_release is outputting in the REALTAG assingment.

Maybe running with with -x would help, as it will print the command outputs as it's run.

Edit: Ah sorry @yermulnik , I see you suggested this!

Edit edit:
Just to tidy up @yermulnik's message:
Can you please replace

./install.sh -b `pwd`/.bin

with

sh -x ./install.sh -b `pwd`/.bin

and attach full output.

Edit edit edit: I wondered if the branching logic around whether curl vs wget was installed was causing the issue: I saw you're using wget in the Github action, so used latest ubuntu docker image (which doesn't have curl or wget), installed wget and ran the command and still seemed to work 🤔

@janani2019
Copy link
Author

janani2019 commented Dec 9, 2024

Sure, here are the logs:

Workflow step:


     - name: install tfswitch
      run: |
            echo "Installing tfswitch locally"
            wget https://raw.githubusercontent.com/warrensbox/terraform-switcher/master/install.sh
             #Get the installer on to your machine
            chmod 755 install.sh            #Make installer executable
            sh -x ./install.sh -b `pwd`/.bin     #Install tfswitch in a location you have permission
            CUSTOMBIN=`pwd`/.bin            #set custom bin path
            export PATH=$PATH:$CUSTOMBIN    #Add custom bin path to PATH environment
            tfswitch -b $CUSTOMBIN/terraform 0.11.7
            terraform -v                    #testing version





LOGS:
```##[debug]Evaluating condition for step: 'install tfswitch'
##[debug]Evaluating: success()
##[debug]Evaluating success:
##[debug]=> true
##[debug]Result: true
##[debug]Starting: install tfswitch
##[debug]Loading inputs
##[debug]Loading env
Run echo "Installing tfswitch locally"
##[debug]Overwrite 'working-directory' base on job defaults.
##[debug]sh -e /__w/_temp/77f106ea-630e-4c3[2](https://github.com/DigitalTitleGroup/seq-infra-tf-federated-iam/actions/runs/12246415568/job/34162251010#step:8:2)-be7a-ace1cfa6d2ce.sh
--2024-12-09 15:48:26--  https://raw.githubusercontent.com/warrensbox/terraform-switcher/master/install.sh
Installing tfswitch locally
Resolving raw.githubusercontent.com (raw.githubusercontent.com)... 185.199.110.1[3](https://github.com/DigitalTitleGroup/seq-infra-tf-federated-iam/actions/runs/12246415568/job/34162251010#step:8:3)3, 185.199.111.133, 185.199.108.133, ...
Connecting to raw.githubusercontent.com (raw.githubusercontent.com)|185.199.110.133|:[4](https://github.com/DigitalTitleGroup/seq-infra-tf-federated-iam/actions/runs/12246415568/job/34162251010#step:8:4)43... connected.
HTTP request sent, awaiting response... 200 OK
Length: 9463 (9.2K) [text/plain]
Saving to: ‘install.sh’

     0K .........                                             100% 11.8K=0.8s

2024-12-09 1[5](https://github.com/DigitalTitleGroup/seq-infra-tf-federated-iam/actions/runs/12246415568/job/34162251010#step:8:5):48:27 (11.8 KB/s) - ‘install.sh’ saved [94[6](https://github.com/DigitalTitleGroup/seq-infra-tf-federated-iam/actions/runs/12246415568/job/34162251010#step:8:6)3/9463]

+ set -e
+ cat /dev/null
+ _logp=6
+ cat /dev/null
+ PROJECT_NAME=terraform-switcher
+ OWNER=warrensbox
+ REPO=terraform-switcher
+ BINARY=tfswitch
+ FORMAT=tar.gz
+ uname_os
+ uname -s
+ tr [:upper:] [:lower:]
+ os=linux
+ echo linux
+ OS=linux
+ uname_arch
+ uname -m
+ arch=x86_64
+ arch=amd64
+ echo amd64
+ ARCH=amd64
+ PREFIX=warrensbox/terraform-switcher
+ PLATFORM=linux/amd64
+ GITHUB_DOWNLOAD=https://github.com/warrensbox/terraform-switcher/releases/download
+ uname_os_check linux
+ uname_os
+ uname -s
+ tr [:upper:] [:lower:]
+ os=linux
+ echo linux
+ os=linux
+ return 0
+ uname_arch_check amd64
+ uname_arch
+ uname -m
+ arch=x86_64
+ arch=amd64
+ echo amd64
+ arch=amd64
+ return 0
+ parse_args -b /__w/seq-infra-tf-federated-iam/seq-infra-tf-federated-iam/.bin
+ BINDIR=/usr/local/bin
+ getopts b:dh? arg
+ BINDIR=/__w/seq-infra-tf-federated-iam/seq-infra-tf-federated-iam/.bin
+ getopts b:dh? arg
+ shift 2
+ TAG=
+ check_platform
+ is_supported_platform linux/amd64
+ platform=linux/amd64
+ found=1
+ found=0
+ return 0
+ true
+ tag_to_version
+ test -z 
+ TAG=latest
+ log_info checking GitHub for tag 'latest'
+ log_priority 6
+ test -z 6
+ [ 6 -le 6 ]
+ log_prefix
+ echo warrensbox/terraform-switcher
+ log_tag 6
+ echo info
+ echoerr warrensbox/terraform-switcher info checking GitHub for tag 'latest'
+ echo warrensbox/terraform-switcher info checking GitHub for tag 'latest'
warrensbox/terraform-switcher info checking GitHub for tag 'latest'
+ github_release warrensbox/terraform-switcher latest
+ owner_repo=warrensbox/terraform-switcher
+ version=latest
+ test -z latest
+ [ latest = latest ]
+ giturl=https://github.com/warrensbox/terraform-switcher/releases/latest
+ http_copy https://github.com/warrensbox/terraform-switcher/releases/latest Accept:application/json
+ mktemp
+ tmp=/tmp/tmp.Zz2HRlrK1E
+ http_download /tmp/tmp.Zz2HRlrK1E https://github.com/warrensbox/terraform-switcher/releases/latest Accept:application/json
+ log_debug http_download https://github.com/warrensbox/terraform-switcher/releases/latest
+ log_priority [7](https://github.com/DigitalTitleGroup/seq-infra-tf-federated-iam/actions/runs/12246415568/job/34162251010#step:8:7)
+ test -z 7
+ [ 7 -le 6 ]
+ return 0
+ is_command curl
+ command -v curl
+ http_download_curl /tmp/tmp.Zz2HRlrK1E https://github.com/warrensbox/terraform-switcher/releases/latest Accept:application/json
+ local_file=/tmp/tmp.Zz2HRlrK1E
+ source_url=https://github.com/warrensbox/terraform-switcher/releases/latest
+ header=Accept:application/json
+ [ -z Accept:application/json ]
+ curl -w %{http_code} -sL -H Accept:application/json -o /tmp/tmp.Zz2HRlrK1E https://github.com/warrensbox/terraform-switcher/releases/latest
+ code=000
+ [ 000 != 200 ]
+ log_debug http_download_curl received HTTP status 000
+ log_priority 7
+ test -z 7
+ [ 7 -le 6 ]
+ return 0
+ return 1
+ return
+ return 1
+ json=
+ REALTAG=
+ test -z 
+ log_crit unable to find 'latest' - use 'latest' or see https://github.com/warrensbox/terraform-switcher/releases for details
+ log_priority 2
+ test -z 2
+ [ 2 -le 6 ]
+ log_prefix
+ echo warrensbox/terraform-switcher
+ log_tag 2
+ echo crit
+ echoerr warrensbox/terraform-switcher crit unable to find 'latest' - use 'latest' or see https://github.com/warrensbox/terraform-switcher/releases for details
+ echo warrensbox/terraform-switcher crit unable to find 'latest' - use 'latest' or see https://github.com/warrensbox/terraform-switcher/releases for details
warrensbox/terraform-switcher crit unable to find 'latest' - use 'latest' or see https://github.com/warrensbox/terraform-switcher/releases for details
+ exit 1
Error: Process completed with exit code 1.```

@yermulnik
Copy link
Collaborator

@janani2019 The problematic bit is this:

+ curl -w %{http_code} -sL -H Accept:application/json -o /tmp/tmp.Zz2HRlrK1E https://github.com/warrensbox/terraform-switcher/releases/latest
+ code=000

cURL encountered some hiccup and hence http_code rendered 000 which may identify something in the way that is blocking connection (ref: https://superuser.com/a/1080420/1241314).

Is your GH Action running on a self-hosted worker?

Could you please add curl -w "%{http_code}\n" -vL -H "Accept:application/json" -o /dev/null https://github.com/warrensbox/terraform-switcher/releases/latest || exit 1 before all the other commands and post output?

@yermulnik
Copy link
Collaborator

yermulnik commented Dec 10, 2024

This actions/runner-images#10009 looks related (if not the same at all).
@janani2019 Please try and upgrade either Git client or cURL to a more newer version as suggested at curl/curl#13845 (comment)

@yermulnik yermulnik reopened this Dec 10, 2024
@janani2019
Copy link
Author

sure I added the curl command and here is the output :

##[debug]Evaluating: success()
##[debug]Evaluating success:
##[debug]=> true
##[debug]Result: true
##[debug]Starting: install tfswitch
##[debug]Loading inputs
##[debug]Loading env
Run curl -w "%{http_code}\n" -vL -H "Accept:application/json" -o /dev/null https://github.com/warrensbox/terraform-switcher/releases/latest || exit 1
##[debug]Overwrite 'working-directory' base on job defaults.
##[debug]sh -e /__w/_temp/41463168-7a6a-4860-871a-7bf[2](https://github.com/DigitalTitleGroup/seq-infra-tf-federated-iam/actions/runs/12246737090/job/34163225824#step:8:2)0947bfbd.sh
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0*   Trying 140.82.112.4:44[3](https://github.com/DigitalTitleGroup/seq-infra-tf-federated-iam/actions/runs/12246737090/job/34163225824#step:8:3)...
* Connected to github.com (1[4](https://github.com/DigitalTitleGroup/seq-infra-tf-federated-iam/actions/runs/12246737090/job/34163225824#step:8:4)0.82.112.4) port 443 (#0)
* ALPN, offering h2
* ALPN, offering http/1.1
* error setting certificate file: /usr/local/share/ca-certificates/ca-certificates.crt
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
* Closing connection 0
curl: ([7](https://github.com/DigitalTitleGroup/seq-infra-tf-federated-iam/actions/runs/12246737090/job/34163225824#step:8:7)7) error setting certificate file: /usr/local/share/ca-certificates/ca-certificates.crt
000
Error: Process completed with exit code 1.
##[debug]Finishing: install tfswitch```


@yermulnik
Copy link
Collaborator

sure I added the curl command and here is the output :

What GHA worker are you using? The error setting certificate file: /usr/local/share/ca-certificates/ca-certificates.crt error looks to have nothing to do with us or GitHub 🤷🏻 That's local to your GHA worker (either OS is too old, or a a package that provides SSL certs is outdated).

@yermulnik
Copy link
Collaborator

@janani2019 Have you been able to upgrade cURL on your GHA worker to see whether this fixes the issue?

@janani2019
Copy link
Author

Thanks @yermulnik It was something to do with the certs. I am able to install tfswitch with no issues..
I see this error when trying to install terraform via tfswitch. Appreciate your help!

##[debug]Evaluating: success()
##[debug]Evaluating success:
##[debug]=> true
##[debug]Result: true
##[debug]Starting: tfswitch version switch
##[debug]Loading inputs
##[debug]Loading env
Run tfswitch
##[debug]Overwrite 'working-directory' base on job defaults.
##[debug]sh -e /__w/_temp/a34188ff-0798-43da-b1aa-8d7adb135cd0.sh
08:[2](https://github.com/DigitalTitleGroup/seq-infra-tf-federated-iam/actions/runs/12260330796/job/34204682512#step:11:2)4:22.258 INFO Reading version from Terraform module at "."  
08:24:22.51[3](https://github.com/DigitalTitleGroup/seq-infra-tf-federated-iam/actions/runs/12260330796/job/34204682512#step:11:3) INFO Reading required version from constraint: "~> 1.5.0"  
08:2[4](https://github.com/DigitalTitleGroup/seq-infra-tf-federated-iam/actions/runs/12260330796/job/34204682512#step:11:4):22.514 INFO Matched version: "1.[5](https://github.com/DigitalTitleGroup/seq-infra-tf-federated-iam/actions/runs/12260330796/job/34204682512#step:11:5).7"  
08:24:22.514 INFO Creating "/github/home/.terraform.versions" directory  
08:24:22.551 INFO Downloading to "/github/home/.terraform.versions/pgp-key.txt"  
08:24:23.328 INFO 7717 bytes downloaded  
08:24:23.329 INFO Downloading "https://releases.hashicorp.com/terraform/1.5.7/terraform_1.5.7_linux_amd[6](https://github.com/DigitalTitleGroup/seq-infra-tf-federated-iam/actions/runs/12260330796/job/34204682512#step:11:6)4.zip"  
08:24:23.329 INFO Downloading to "/github/home/.terraform.versions/terraform_1.5.[7](https://github.com/DigitalTitleGroup/seq-infra-tf-federated-iam/actions/runs/12260330796/job/34204682512#step:11:7)_linux_amd64.zip"  
08:24:26.962 INFO 21019[8](https://github.com/DigitalTitleGroup/seq-infra-tf-federated-iam/actions/runs/12260330796/job/34204682512#step:11:8)80 bytes downloaded  
08:24:26.[9](https://github.com/DigitalTitleGroup/seq-infra-tf-federated-iam/actions/runs/12260330796/job/34204682512#step:11:9)62 INFO Downloading "https://releases.hashicorp.com/terraform/1.5.7/terraform_1.5.7_SHA256SUMS"  
08:24:26.962 INFO Downloading to "/github/home/.terraform.versions/terraform_1.5.7_SHA256SUMS"  
08:24:26.989 INFO [13](https://github.com/DigitalTitleGroup/seq-infra-tf-federated-iam/actions/runs/12260330796/job/34204682512#step:11:14)78 bytes downloaded  
08:24:26.989 INFO Downloading "https://releases.hashicorp.com/terraform/1.5.7/terraform_1.5.7_SHA256SUMS.72D7468F.sig"  
08:24:26.989 INFO Downloading to "/github/home/.terraform.versions/terraform_1.5.7_SHA256SUMS.72D7468F.sig"  
08:24:27.0[17](https://github.com/DigitalTitleGroup/seq-infra-tf-federated-iam/actions/runs/12260330796/job/34204682512#step:11:18) INFO 566 bytes downloaded  
08:24:27.017 INFO Verifying signature of checksum file...  
08:24:27.020 INFO Checksum file signature verification successful.  
08:24:27.035 INFO Deleting "/github/home/.terraform.versions/terraform_1.5.7_SHA256SUMS"  
08:24:27.035 INFO Deleting "/github/home/.terraform.versions/terraform_1.5.7_SHA256SUMS.72D7468F.sig"  
08:24:27.427 FATAL 
		Unable to create new symlink.
		Maybe symlink already exist. Try removing existing symlink manually.
		Try running "unlink "/usr/local/bin/terraform"" to remove existing symlink.
		If error persist, you may not have the permission to create a symlink at "/usr/local/bin/terraform".
		Error: symlink /github/home/.terraform.versions/terraform_1.5.7 /usr/local/bin/terraform: file exists
		  
Error: Process completed with exit code 1.
##[debug]Finishing: tfswitch version switch```

@yermulnik
Copy link
Collaborator

Thanks @yermulnik It was something to do with the certs. I am able to install tfswitch with no issues..

Glad you've managed it.

I see this error when trying to install terraform via tfswitch. Appreciate your help!

Is that the output from tfswitch -b $CUSTOMBIN/terraform 0.11.7 command (which should not attempt to install symlink to /usr/local/bin/)?

ps: closed issue since original issue had been resolved.

@yermulnik
Copy link
Collaborator

I also see that /usr/local/bin/terraform exists on your GHA worker, so you'd want to put $CUSTOMBIN in front of the PATH env var: export PATH="$CUSTOMBIN:$PATH" instead of export PATH=$PATH:$CUSTOMBIN.

@janani2019
Copy link
Author

janani2019 commented Dec 10, 2024

Sure, updated that!

workflow steps:


   - name: install tfswitch
      run: |
             echo "Installing tfswitch locally"
             wget https://raw.githubusercontent.com/warrensbox/terraform-switcher/master/install.sh | bash
             #Get the installer on to your machine
             chmod 755 install.sh            #Make installer executable
             sh ./install.sh -b /usr/local/bin
             #Install tfswitch in a location you have permission
             CUSTOMBIN=/usr/local/bin
             #set custom bin path
             export PATH="$CUSTOMBIN:$PATH"    #Add custom bin path to PATH environment
             echo "find where tfswitch is installed"
             which tfswitch 

    - name: tfswitch version switch
      id: tfswitch_init
      run: tfswitch -b /usr/local/bin/terraform
      
      
      
      
      LOGS:
      
      ##[debug]Evaluating condition for step: 'install tfswitch'
##[debug]Evaluating: success()
##[debug]Evaluating success:
##[debug]=> true
##[debug]Result: true
##[debug]Starting: install tfswitch
##[debug]Loading inputs
##[debug]Loading env
Run echo "Installing tfswitch locally"
##[debug]Overwrite 'working-directory' base on job defaults.
##[debug]sh -e /__w/_temp/0dd8b5ee-809b-4e04-9e06-85a7977d9107.sh
--[2](https://github.com/DigitalTitleGroup/seq-infra-tf-federated-iam/actions/runs/12261031650/job/34207085813#step:8:2)024-12-10 09:05:44--  https://raw.githubusercontent.com/warrensbox/terraform-switcher/master/install.sh
Installing tfswitch locally
Resolving raw.githubusercontent.com (raw.githubusercontent.com)... 185.199.109.1[3](https://github.com/DigitalTitleGroup/seq-infra-tf-federated-iam/actions/runs/12261031650/job/34207085813#step:8:3)3, 185.199.111.133, 185.199.110.133, ...
Connecting to raw.githubusercontent.com (raw.githubusercontent.com)|185.199.109.133|:[4](https://github.com/DigitalTitleGroup/seq-infra-tf-federated-iam/actions/runs/12261031650/job/34207085813#step:8:4)43... connected.
HTTP request sent, awaiting response... 200 OK
Length: 9463 (9.2K) [text/plain]
Saving to: ‘install.sh’
     0K .........                                             100% 17.4K=0.[5](https://github.com/DigitalTitleGroup/seq-infra-tf-federated-iam/actions/runs/12261031650/job/34207085813#step:8:5)s
2024-12-10 09:05:45 (17.4 KB/s) - ‘install.sh’ saved [94[6](https://github.com/DigitalTitleGroup/seq-infra-tf-federated-iam/actions/runs/12261031650/job/34207085813#step:8:6)3/9463]
warrensbox/terraform-switcher info checking GitHub for tag 'latest'
warrensbox/terraform-switcher info found version: v1.2.4 for latest/linux/amd64
warrensbox/terraform-switcher info installed /usr/local/bin/tfswitch
find where tfswitch is installed
/usr/local/bin/tfswitch
##[debug]Finishing: install tfswitch
3s
##[debug]Evaluating condition for step: 'tfswitch version switch'
##[debug]Evaluating: success()
##[debug]Evaluating success:
##[debug]=> true
##[debug]Result: true
##[debug]Starting: tfswitch version switch
##[debug]Loading inputs
##[debug]Loading env
Run tfswitch -b /usr/local/bin/terraform
##[debug]Overwrite 'working-directory' base on job defaults.
##[debug]sh -e /__w/_temp/6d3fc56a-108[7](https://github.com/DigitalTitleGroup/seq-infra-tf-federated-iam/actions/runs/12261031650/job/34207085813#step:8:7)-46d9-9a67-03e5e93e74d2.sh
09:05:4[8](https://github.com/DigitalTitleGroup/seq-infra-tf-federated-iam/actions/runs/12261031650/job/34207085813#step:8:8).230 INFO Reading version from Terraform module at "."  
0[9](https://github.com/DigitalTitleGroup/seq-infra-tf-federated-iam/actions/runs/12261031650/job/34207085813#step:8:9):05:48.693 INFO Reading required version from constraint: "~> 1.5.0"  
09:05:48.694 INFO Matched version: "1.5.7"  
09:05:48.694 INFO Creating "/github/home/.terraform.versions" directory  
09:05:48.727 INFO Downloading to "/github/home/.terraform.versions/pgp-key.txt"  
09:05:49.162 INFO 7717 bytes downloaded  
09:05:49.162 INFO Downloading "https://releases.hashicorp.com/terraform/1.5.7/terraform_1.5.7_linux_amd64.zip"  
09:05:49.162 INFO Downloading to "/github/home/.terraform.versions/terraform_1.5.7_linux_amd64.zip"  
09:05:51.278 INFO 21019880 bytes downloaded  
09:05:51.278 INFO Downloading "https://releases.hashicorp.com/terraform/1.5.7/terraform_1.5.7_SHA[25](https://github.com/DigitalTitleGroup/seq-infra-tf-federated-iam/actions/runs/12261031650/job/34207085813#step:8:26)6SUMS"  
09:05:51.278 INFO Downloading to "/github/home/.terraform.versions/terraform_1.5.7_SHA256SUMS"  
09:05:51.303 INFO 1378 bytes downloaded  
09:05:51.303 INFO Downloading "https://releases.hashicorp.com/terraform/1.5.7/terraform_1.5.7_SHA256SUMS.72D7468F.sig"  
09:05:51.303 INFO Downloading to "/github/home/.terraform.versions/terraform_1.5.7_SHA256SUMS.72D7468F.sig"  
09:05:51.3[29](https://github.com/DigitalTitleGroup/seq-infra-tf-federated-iam/actions/runs/12261031650/job/34207085813#step:8:30) INFO 566 bytes downloaded  
09:05:51.329 INFO Verifying signature of checksum file...  
09:05:51.3[32](https://github.com/DigitalTitleGroup/seq-infra-tf-federated-iam/actions/runs/12261031650/job/34207085813#step:8:33) INFO Checksum file signature verification successful.  
09:05:51.348 INFO Deleting "/github/home/.terraform.versions/terraform_1.5.7_SHA256SUMS"  
09:05:51.[34](https://github.com/DigitalTitleGroup/seq-infra-tf-federated-iam/actions/runs/12261031650/job/34207085813#step:8:35)8 INFO Deleting "/github/home/.terraform.versions/terraform_1.5.7_SHA256SUMS.72D7468F.sig"  
09:05:51.719 FATAL 
		Unable to create new symlink.
		Maybe symlink already exist. Try removing existing symlink manually.
		Try running "unlink "/usr/local/bin/terraform"" to remove existing symlink.
		If error persist, you may not have the permission to create a symlink at "/usr/local/bin/terraform".
		Error: symlink /github/home/.terraform.versions/terraform_[1](https://github.com/DigitalTitleGroup/seq-infra-tf-federated-iam/actions/runs/12261031650/job/34207085813#step:9:1).5.7 /usr/local/bin/terraform: file exists
		  
Error: Process completed with exit code 1.
##[debug]Finishing: tfswitch version switch

@janani2019
Copy link
Author

I was able to remove the symlink and it's all good now. Thank you for your help!

@yermulnik
Copy link
Collaborator

Glad to hear.
You don't need to supply -b for /usr/local/bin as /usr/local/bin is implied (is default value for -b arg).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants