Skip to content

tgswitch binary fails on Alpine / musl due to dynamic glibc linking (inconsistent vs tfswitch static build) #147

@ox1depl

Description

@ox1depl

Hi,
I noticed that tgswitch cannot be executed in Alpine-based environments (and other musl-based or minimal containers), while tfswitch — a very similar tool — works without issues.

The reason is that the tgswitch binary is built as a dynamically linked glibc executable, while tfswitch is built as a fully static binary, which makes it portable and compatible with Alpine.

Here is the comparison:

$ file tgswitch
tgswitch: ELF 64-bit LSB executable, x86-64, dynamically linked,
interpreter /lib64/ld-linux-x86-64.so.2, ...

$ file tfswitch
tfswitch: ELF 64-bit LSB executable, x86-64, statically linked, ...

Because of the dynamic glibc dependency, running tgswitch inside Alpine (musl) or ARM64 containers throws:

Dynamic loader not found: /lib64/ld-linux-x86-64.so.2
This usually means you’re running an x86 program on an arm64 OS 
or a glibc executable on a musl distro (e.g. Alpine).

Why this is a problem
• tgswitch cannot be used in Alpine-based CI/CD environments (GitLab CI, GitHub Actions, lightweight containers).
• tgswitch is not multi-arch compatible (amd64-only dynamic build).
• The behavior is inconsistent with tfswitch, which works everywhere due to static linking.
• Tools like this (Terraform/Gcloud switchers) are typically expected to be fully portable.

Suggested fixes

  1. Provide a statically linked release binary (preferred)
    Example Go build flags:
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 \
  go build -ldflags "-s -w -extldflags=-static"
  1. Provide a musl-based build for Alpine
    e.g. linux-amd64-musl or linux-arm64-musl

Environment details
• Base image: Alpine (musl)
• Architecture: x86_64 (amd64)
• Error:
Dynamic loader not found: /lib64/ld-linux-x86-64.so.2

Thank you

Thanks a lot for maintaining this tool — it’s extremely useful in multi-environment Terraform workflows and we’d really like to use tgswitch in the same way as tfswitch.
I truly appreciate your work and time, and I hope this report helps improve the portability of the project.

Thanks again! 🙏

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions