Skip to content

ENOENT & symbol not found errors when using NPM in Alpine Linux Docker image #1034

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

Open
1 task done
mattref opened this issue Jan 31, 2025 · 3 comments
Open
1 task done
Assignees
Labels
bug Something isn't working

Comments

@mattref
Copy link

mattref commented Jan 31, 2025

Is there an existing issue for this?

  • I have searched the existing issues

Description of the bug

When using an Alpine Linux based Docker image (i.e., node:alpine) and trying to invoke git-cliff via the NPM installation option, one is greeted with an ENOENT error as node_modules/git-cliff-linux-x64/bin/git-cliff is invoked.

If you try installing gcompat or libc6-compat via apk in an attempt to resolve this, the error changes from ENOENT to symbol not found.

I've tried various combinations of gcompat, libc6-compat, libstdc++, etc. and cannot get it working in Alpine Linux. The minute I switch to a non-Alpine variant, such as node:22-slim, it "just works".

Steps To Reproduce

  1. In a new, empty folder, initialize a basic Git repo:
git init
  1. In the same folder, create a new Dockerfile
  2. In the Dockerfile, add the following:
FROM node:alpine

WORKDIR /app

COPY .git ./.git

RUN apk update && apk upgrade

RUN npm init -y \
    && npm install git-cliff

RUN npx git-cliff -o CHANGELOG.md
  1. Attempt to build the Docker image:
docker build --progress=plain .
  1. Observe the build failure:
#10 [6/6] RUN npx git-cliff -o CHANGELOG.md
#10 0.968 node:internal/child_process:285
#10 0.968       const err = new ErrnoException(exitCode, syscall);
#10 0.968                   ^
#10 0.968
#10 0.968 Error: Command failed with ENOENT: /app/node_modules/git-cliff-linux-x64/bin/git-cliff -o CHANGELOG.md
#10 0.968 spawn /app/node_modules/git-cliff-linux-x64/bin/git-cliff ENOENT
#10 0.968     at ChildProcess._handle.onexit (node:internal/child_process:285:19)
#10 0.968     at onErrorNT (node:internal/child_process:483:16)
#10 0.968     at process.processTicksAndRejections (node:internal/process/task_queues:90:21) {
#10 0.968   errno: -2,
#10 0.968   code: 'ENOENT',
#10 0.968   syscall: 'spawn /app/node_modules/git-cliff-linux-x64/bin/git-cliff',
#10 0.968   path: '/app/node_modules/git-cliff-linux-x64/bin/git-cliff',

...
  1. Now, modify the Dockerfile so that we install gcompat before running our NPM commands
-RUN apk update && apk upgrade

+RUN apk update && apk upgrade && apk add --no-cache gcompat
  1. Re-run the Docker build via docker build --progress=plain . and observe a slightly different build failure:
#10 [6/6] RUN npx git-cliff -o CHANGELOG.md
#10 0.885 Error relocating /app/node_modules/git-cliff-linux-x64/bin/git-cliff: __res_init: symbol not found
#10 0.885 Error relocating /app/node_modules/git-cliff-linux-x64/bin/git-cliff: posix_fallocate64: symbol not found
#10 0.890 file:///app/node_modules/execa/lib/error.js:60
#10 0.890               error = new Error(message);
#10 0.890                       ^
#10 0.890
#10 0.890 Error: Command failed with exit code 127: /app/node_modules/git-cliff-linux-x64/bin/git-cliff -o CHANGELOG.md
#10 0.890     at makeError (file:///app/node_modules/execa/lib/error.js:60:11)
#10 0.890     at handlePromise (file:///app/node_modules/execa/index.js:124:26)
#10 0.890     at process.processTicksAndRejections (node:internal/process/task_queues:105:5)
#10 0.890     at async run (file:///app/node_modules/git-cliff/lib/cli/cli.js:64:25) {

...

Expected behavior

I expect the Docker image to build without any errors, as it would if I was using a non-Alpine Linux base image.

Screenshots / Logs

No response

Software information

  • Operating system: Windows 10, Alpine Linux for Docker Image
  • Rust version: N/A
  • Project version: 2.8.0 (I've also tested this on 2.7.0 and noticed the same issues)
  • Docker Image: node:alpine (Docker Hub), node:22-alpine (Docker Hub)

Additional context

No response

@mattref mattref added the bug Something isn't working label Jan 31, 2025
Copy link

welcome bot commented Jan 31, 2025

Thanks for opening your first issue at git-cliff! Be sure to follow the issue template! ⛰️

@git-wang-hub
Copy link

Has this problem been solved?

@orhun
Copy link
Owner

orhun commented Feb 22, 2025

Can confirm:

$ ldd ./node_modules/git-cliff-linux-x64/bin/git-cliff
        /lib64/ld-linux-x86-64.so.2 (0x7c9ffb4b0000)
        libgcc_s.so.1 => /usr/lib/libgcc_s.so.1 (0x7c9ffa640000)
        librt.so.1 => /lib64/ld-linux-x86-64.so.2 (0x7c9ffb4b0000)
        libpthread.so.0 => /lib64/ld-linux-x86-64.so.2 (0x7c9ffb4b0000)
        libm.so.6 => /lib64/ld-linux-x86-64.so.2 (0x7c9ffb4b0000)
        libdl.so.2 => /lib64/ld-linux-x86-64.so.2 (0x7c9ffb4b0000)
        libc.so.6 => /lib64/ld-linux-x86-64.so.2 (0x7c9ffb4b0000)
Error relocating ./node_modules/git-cliff-linux-x64/bin/git-cliff: __snprintf_chk: symbol not found
Error relocating ./node_modules/git-cliff-linux-x64/bin/git-cliff: __res_init: symbol not found
Error relocating ./node_modules/git-cliff-linux-x64/bin/git-cliff: __register_atfork: symbol not found
Error relocating ./node_modules/git-cliff-linux-x64/bin/git-cliff: __memcpy_chk: symbol not found
Error relocating ./node_modules/git-cliff-linux-x64/bin/git-cliff: posix_fallocate64: symbol not found
Error relocating ./node_modules/git-cliff-linux-x64/bin/git-cliff: __vsnprintf_chk: symbol not found
Error relocating ./node_modules/git-cliff-linux-x64/bin/git-cliff: __strncpy_chk: symbol not found
Error relocating ./node_modules/git-cliff-linux-x64/bin/git-cliff: gnu_get_libc_version: symbol not found

Seems related: https://github.com/sgerrand/alpine-pkg-glibc/issues/176

The binaries that are being installed via NPM package is built in the CI using the ubuntu-22.04 runner. Maybe there is a incompatibility between the glibc version in the Docker image and the binary?

Unfortunately there is no MUSL binaries built in the CI right now. See the full build matrix here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants