Downloaded file in pipeline cannot be found when attempting to execute it

I’m downloading a binary file in a pipeline and when I try to execute it I get a “file not found” error, but previous commands in the pipeline clearly show the file being there and being executable.

This is the pipeline yaml.

"Deploy CoreOS Template":
  image: docker.io/alpine:3.21
  environment: $CI_COMMIT_BRANCH
  variables:
    BWS_PROJECT_ID: redacted
    BWS_VERSION: 1.0.0
  before_script:
    - apk -U add ansible ansible-core curl unzip file
    - curl -LO "https://github.com/bitwarden/sdk/releases/download/bws-v$BWS_VERSION/bws-x86_64-unknown-linux-gnu-$BWS_VERSION.zip"
    - unzip -o bws-x86_64-unknown-linux-gnu-$BWS_VERSION.zip
  script:
    - file bws
    - ls -lt bws
    - ./bws run --project-id $BWS_PROJECT_ID -- 'ansible-playbook -e delete_template=true -e ansible_python_interpreter=/usr/bin/python3 coreos-template.yml'

The end of the job output is this;

$ curl -LO "https://github.com/bitwarden/sdk/releases/download/bws-v$BWS_VERSION/bws-x86_64-unknown-linux-gnu-$BWS_VERSION.zip"
  % 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
100 4931k  100 4931k    0     0  5358k      0 --:--:-- --:--:-- --:--:-- 5358k
$ unzip -o bws-x86_64-unknown-linux-gnu-$BWS_VERSION.zip
Archive:  bws-x86_64-unknown-linux-gnu-1.0.0.zip
  inflating: bws                     
$ file bws
bws: ELF 64-bit LSB pie executable, x86-64, version 1 (SYSV), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, for GNU/Linux 2.0.0, stripped
$ ls -lt bws
-rwxr-xr-x    1 root     root      11391088 Sep 26  2024 bws
$ ./bws run --project-id $BWS_PROJECT_ID -- 'ansible-playbook -e delete_template=true -e ansible_python_interpreter=/usr/bin/python3 coreos-template.yml'
/bin/sh: eval: line 172: ./bws: not found

Versions

  • Self-managed
  • GitLab.com SaaS
  • Dedicated
  • Self-hosted Runners

Versions

  • GitLab: 17.8.5 ee
  • GitLab Runner, if self-hosted: latest container image

I can solve this myself. I forgot that Alpine is musl-based so ldd ./bws shows libc being missing from the dynamically linked bws binary.

$ ldd ./bws
	/lib64/ld-linux-x86-64.so.2 (0x7f87b441d000)
	libm.so.6 => /lib64/ld-linux-x86-64.so.2 (0x7f87b441d000)
	libpthread.so.0 => /lib64/ld-linux-x86-64.so.2 (0x7f87b441d000)
	libc.so.6 => /lib64/ld-linux-x86-64.so.2 (0x7f87b441d000)
	libdl.so.2 => /lib64/ld-linux-x86-64.so.2 (0x7f87b441d000)
Error loading shared library ld-linux-x86-64.so.2: No such file or directory (needed by ./bws)
Error relocating ./bws: gnu_get_libc_version: symbol not found
Error relocating ./bws: __res_init: symbol not found