terraform-switcher icon indicating copy to clipboard operation
terraform-switcher copied to clipboard

Static build of `tfswitch` unavailable?

Open krish7919 opened this issue 2 years ago • 2 comments

I have just installed the latest release of tfswitch on my CI container based on alpine 3.14 and the command wouldn't run. While debugging, I discovered that tfswitch is a dynamically built binary instead of a statically built one.

Please find below a comparison of the outputs of the ldd command from within my container:

/opt/terraform-switcher-0.13.1201 # ldd /opt/terraform-0.11.14/terraform-0.11 
/lib/ld-musl-x86_64.so.1: /opt/terraform-0.11.14/terraform-0.11: Not a valid dynamic program
/opt/terraform-switcher-0.13.1201 # ldd tfswitch 
	/lib64/ld-linux-x86-64.so.2 (0x7f642eb4c000)
	libpthread.so.0 => /lib64/ld-linux-x86-64.so.2 (0x7f642eb4c000)
	libc.so.6 => /lib64/ld-linux-x86-64.so.2 (0x7f642eb4c000)
/opt/terraform-switcher-0.13.1201 # 

Can we provide static binaries in the releases page for downloads starting with the previous release please?

krish7919 avatar Feb 24 '22 11:02 krish7919

For others hitting the same issue, I have used the following snippet for now:

RUN TERRAFORM_SWITCHER_VERSION="0.13.1201" \
    && mkdir -p "/opt/terraform-switcher" \
    && cd "/opt/terraform-switcher" \
    && curl -sLO https://github.com/warrensbox/terraform-switcher/archive/refs/tags/${TERRAFORM_SWITCHER_VERSION}.tar.gz \
    && tar xzf 0.13.1201.tar.gz \
    && cd terraform-switcher-0.13.1201 \
    && CGO_ENABLED=0 GOOS=linux GOARCH=amd64 GO111MODULE=on go build \
    && mv terraform-switcher ../tfswitch \
    && go clean -x -r -cache -modcache -testcache \
    && cd .. && rm -rf \
        terraform-switcher-0.13.1201 0.13.1201.tar.gz \
        /root/.cache \
        /tmp/* \
        /usr/share/doc \
        /usr/share/doc-base \
        /usr/share/man \
        /var/tmp/*

# Put terrafom-switcher into the environment
ENV PATH="/opt/terraform-switcher:${PATH}"

...
...
RUN ..
    && echo "---- Terraform 0.10.8" \
    && tfswitch 0.10.8 && terraform --version \
    && echo "---- Terraform 0.11.6" \
    && tfswitch 0.11.14 && terraform --version \
    && echo "---- Terraform 0.13.6" \
    && tfswitch 0.13.6 && terraform --version \
    && echo "---- Terraform 1.1.2" \
    && tfswitch 1.1.2 && terraform --version \

krish7919 avatar Feb 24 '22 11:02 krish7919

Bump, anyone?

krish7919 avatar Jun 21 '22 11:06 krish7919

@yermulnik did your pr #353 possibly fix this issue?

MatrixCrawler avatar Apr 04 '24 14:04 MatrixCrawler

Hopefully (and most probably) yes. Though that feature hasn't yet been released (as the release automation is borked a bit — I notified @warrensbox about it, though not sure when he will be able to look into it again).

yermulnik avatar Apr 04 '24 14:04 yermulnik

I'm using temp:

curl -L https://raw.githubusercontent.com/warrensbox/terraform-switcher/release/install.sh > install.sh chmod +x install.sh ./install.sh "0.13.1300"

franviera92 avatar Apr 04 '24 15:04 franviera92

I'm using temp:

For what? The most recent before v1 is 0.13.1308 and, to the best of my knowledge, none of the released versions are statically built.

yermulnik avatar Apr 04 '24 16:04 yermulnik

I'm using temp:

For what? The most recent before v1 is 0.13.1308 and, to the best of my knowledge, none of the released versions are statically built.

this work too with

echo "Download tfswitch"
#curl -L https://raw.githubusercontent.com/warrensbox/terraform-switcher/release/install.sh | bash

curl -L https://raw.githubusercontent.com/warrensbox/terraform-switcher/release/install.sh > install.sh 
chmod +x install.sh
./install.sh "0.13.1308"

franviera92 avatar Apr 04 '24 17:04 franviera92

@yermulnik our release pipeline is now working. Can we confirm that this issue is solved and can therefor be closed?

MatrixCrawler avatar Jun 04 '24 14:06 MatrixCrawler

I guess, yes. Closing now.

yermulnik avatar Jun 04 '24 15:06 yermulnik