/bin/sh: eval: line 97: ./mybinary not found

I’m attempting to run a binary artifact in a job that was produced in an earlier job. Here’s the job execution log:

Running with gitlab-runner 11.11.2 (ac2a293c)
  on docker-auto-scale 0277ea0f
Using Docker executor with image alpine ...
Pulling docker image alpine ...
Using docker image sha256:055936d3920576da37aa9bc460d70c5f212028bda1c08c0879aedf03d7a66ea1 for alpine ...
Running on runner-0277ea0f-project-10880841-concurrent-0 via runner-0277ea0f-srm-1560230988-68c05137...
Initialized empty Git repository in /builds/group/repo/.git/
Fetching changes...
Created fresh repository.
From https://gitlab.com/group/repo
 * [new branch]      master     -> origin/master
Checking out b8d63ff7 as master...
Skipping Git submodules setup
Downloading artifacts for compile-linux (228759107)...
Downloading artifacts from coordinator... ok        id=228759107 responseStatus=200 OK token=64hfxDrL
$ mkdir -p $GOPATH/src/$(dirname $REPO_NAME)
'/src/gitlab.com/group/repp' -> '/builds/group/repo'
$ apk add ca-certificates
fetch http://dl-cdn.alpinelinux.org/alpine/v3.9/main/x86_64/APKINDEX.tar.gz
fetch http://dl-cdn.alpinelinux.org/alpine/v3.9/community/x86_64/APKINDEX.tar.gz
(1/1) Installing ca-certificates (20190108-r0)
Executing busybox-1.29.3-r10.trigger
Executing ca-certificates-20190108-r0.trigger
OK: 6 MiB in 15 packages
$ ls -la ./mybinary
-rwxr-xr-x    1 root     root      12659960 Jun 11 05:30 ./mybinary
$ ./mybinary -app=${APP_ID} -secret=${SECRET} -output=output.ext
/bin/sh: eval: line 97: ./mybinary: not found
ERROR: Job failed: exit code 127

Here’s the .gitlab-ci.yml file:

image: golang:latest

    REPO_NAME: gitlab.com/group/repo

    - mkdir -p $GOPATH/src/$(dirname $REPO_NAME)
    - ln -svf $CI_PROJECT_DIR $GOPATH/src/$REPO_NAME
    - cd $GOPATH/src/$REPO_NAME

    - build
    - run

    stage: build
      - go build -o mybinary
        - mybinary

    stage: run
    image: alpine
      - apk add ca-certificates
      - ls -la ./mybinary
      - ./mybinary -app=${APP_ID} -secret=${SECRET} -output=output.ext

I’m totally stumped as to why it can’t find mybinary, since in the command right before it I used the ls command to print out information about it (and it is executable). Any ideas what’s wrong with my setup?

I got unblocked by using the debian image instead of alpine, but I’d still like to know why it didn’t work with alpine. =/

I ran into a similar problem and found out what the problem is.

In your stage compile-linux you build the mybinary using the docker image golang. That is Debian based, and because Debian uses the GNU libc, or glibc, mybinary is linked against glibc.

The problem now is that you are using the alpine image in the run job. Alpine doesn’t use glibc, but rather musl libc, and that’s why mybinary can’t find its dependencies.

sh comments this with a rather unhelpful “not found”.

Another solution other than using debian for all jobs would be to use golang:latest-alpine as image.

Hope that helps!