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

Static build of tfswitch unavailable? #213

Open
krish7919 opened this issue Feb 24, 2022 · 7 comments · Fixed by #353
Open

Static build of tfswitch unavailable? #213

krish7919 opened this issue Feb 24, 2022 · 7 comments · Fixed by #353

Comments

@krish7919
Copy link

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
Copy link
Author

krish7919 commented Feb 24, 2022

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
Copy link
Author

Bump, anyone?

@MatrixCrawler MatrixCrawler linked a pull request Apr 4, 2024 that will close this issue
@MatrixCrawler
Copy link
Collaborator

MatrixCrawler commented Apr 4, 2024

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

@yermulnik
Copy link
Collaborator

yermulnik commented Apr 4, 2024

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).

@franviera92

This comment was marked as off-topic.

@yermulnik

This comment was marked as off-topic.

@franviera92

This comment was marked as off-topic.

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

Successfully merging a pull request may close this issue.

4 participants