Automattic / Automattic/node-canvas
CI installation for node 18 alpine "printf: Operation not permitted"
- Dominant language
- JavaScript
- Stars
- 10.7k
- Forks
- 1.2k
- Avg merge
- 4d 8h
- Merged PRs (30d)
- 1
Description
## Issue or Feature
- [x] If this is an issue with installation, I have read the [troubleshooting guide](https://github.com/Automattic/node-canvas/issues/1511).
Installation in Gitlab CI using node:18.16-alpine image fails with weird `printf: Operation not permitted` error.
Locally can build the docker image just fine!
Included is the tail of the verbose logs of the pipeline:
```bash
....
npm ERR! gyp verb get node dir target node version installed: 18.16.0
npm ERR! gyp verb build dir attempting to create "build" dir: /usr/src/app/node_modules/canvas/build
npm ERR! gyp verb build dir "build" dir needed to be created? Yes
npm ERR! gyp verb python symlink creating symlink to "/usr/bin/python3" at "/usr/src/app/node_modules/canvas/build/node_gyp_bins/python3"
npm ERR! gyp verb build/config.gypi creating config file
npm ERR! gyp verb build/config.gypi writing out config file: /usr/src/app/node_modules/canvas/build/config.gypi
npm ERR! gyp verb config.gypi checking for gypi file: /usr/src/app/node_modules/canvas/config.gypi
npm ERR! gyp verb common.gypi checking for gypi file: /usr/src/app/node_modules/canvas/common.gypi
npm ERR! gyp verb gyp gyp format was not specified; forcing "make"
npm ERR! gyp info spawn /usr/bin/python3
npm ERR! gyp info spawn args [
npm ERR! gyp info spawn args '/usr/local/lib/node_modules/npm/node_modules/node-gyp/gyp/gyp_main.py',
npm ERR! gyp info spawn args 'binding.gyp',
npm ERR! gyp info spawn args '-f',
npm ERR! gyp info spawn args 'make',
npm ERR! gyp info spawn args '-I',
npm ERR! gyp info spawn args '/usr/src/app/node_modules/canvas/build/config.gypi',
npm ERR! gyp info spawn args '-I',
npm ERR! gyp info spawn args '/usr/local/lib/node_modules/npm/node_modules/node-gyp/addon.gypi',
npm ERR! gyp info spawn args '-I',
npm ERR! gyp info spawn args '/root/.cache/node-gyp/18.16.0/include/node/common.gypi',
npm ERR! gyp info spawn args '-Dlibrary=shared_library',
npm ERR! gyp info spawn args '-Dvisibility=default',
npm ERR! gyp info spawn args '-Dnode_root_dir=/root/.cache/node-gyp/18.16.0',
npm ERR! gyp info spawn args '-Dnode_gyp_dir=/usr/local/lib/node_modules/npm/node_modules/node-gyp',
npm ERR! gyp info spawn args '-Dnode_lib_file=/root/.cache/node-gyp/18.16.0/<(target_arch)/node.lib',
npm ERR! gyp info spawn args '-Dmodule_root_dir=/usr/src/app/node_modules/canvas',
npm ERR! gyp info spawn args '-Dnode_engine=v8',
npm ERR! gyp info spawn args '--depth=.',
npm ERR! gyp info spawn args '--no-parallel',
npm ERR! gyp info spawn args '--generator-output',
npm ERR! gyp info spawn args 'build',
npm ERR! gyp info spawn args '-Goutput_dir=.'
npm ERR! gyp info spawn args ]
npm ERR! gyp info ok
npm ERR! gyp info it worked if it ends with ok
npm ERR! gyp verb cli [
npm ERR! gyp verb cli '/usr/local/bin/node',
npm ERR! gyp verb cli '/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js',
npm ERR! gyp verb cli 'build',
npm ERR! gyp verb cli '--fallback-to-build',
npm ERR! gyp verb cli '--update-binary',
npm ERR! gyp verb cli '--module=/usr/src/app/node_modules/canvas/build/Release/canvas.node',
npm ERR! gyp verb cli '--module_name=canvas',
npm ERR! gyp verb cli '--module_path=/usr/src/app/node_modules/canvas/build/Release',
npm ERR! gyp verb cli '--napi_version=8',
npm ERR! gyp verb cli '--node_abi_napi=napi',
npm ERR! gyp verb cli '--napi_build_version=0',
npm ERR! gyp verb cli '--node_napi_label=node-v108'
npm ERR! gyp verb cli ]
npm ERR! gyp info using node-gyp@9.3.1
npm ERR! gyp info using node@18.16.0 | linux | x64
npm ERR! gyp verb command build []
npm ERR! gyp verb build type Release
npm ERR! gyp verb architecture x64
npm ERR! gyp verb node dev dir /root/.cache/node-gyp/18.16.0
npm ERR! gyp verb `which` succeeded for `make` /usr/bin/make
npm ERR! gyp verb bin symlinks adding symlinks (such as Python), at "/usr/src/app/node_modules/canvas/build/node_gyp_bins", to PATH
npm ERR! gyp info spawn make
npm ERR! gyp info spawn args [ 'V=1', 'BUILDTYPE=Release', '-C', 'build' ]
npm ERR! make: printf: Operation not permitted
npm ERR! make: *** [canvas-postbuild.target.mk:22: Release/obj.target/canvas-postbuild.node] Error 127
npm ERR! gyp ERR! build error
npm ERR! gyp ERR! stack Error: `make` failed with exit code: 2
npm ERR! gyp ERR! stack at ChildProcess.onExit (/usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:203:23)
npm ERR! gyp ERR! stack at ChildProcess.emit (node:events:513:28)
npm ERR! gyp ERR! stack at ChildProcess._handle.onexit (node:internal/child_process:291:12)
npm ERR! gyp ERR! System Linux 5.10.162+
npm ERR! gyp ERR! command "/usr/local/bin/node" "/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "build" "--fallback-to-build" "--update-binary" "--module=/usr/src/app/node_modules/canvas/build/Release/canvas.node" "--module_name=canvas" "--module_path=/usr/src/app/node_modules/canvas/build/Release" "--napi_version=8" "--node_abi_napi=napi" "--napi_build_version=0" "--node_napi_label=node-v108"
npm ERR! gyp ERR! cwd /usr/src/app/node_modules/canvas
npm ERR! gyp ERR! node -v v18.16.0
npm ERR! gyp ERR! node-gyp -v v9.3.1
npm ERR! gyp ERR! not ok
npm ERR! node-pre-gyp ERR! build error
npm ERR! node-pre-gyp ERR! stack Error: Failed to execute '/usr/local/bin/node /usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js build --fallback-to-build --update-binary --module=/usr/src/app/node_modules/canvas/build/Release/canvas.node --module_name=canvas --module_path=/usr/src/app/node_modules/canvas/build/Release --napi_version=8 --node_abi_napi=napi --napi_build_version=0 --node_napi_label=node-v108' (1)
npm ERR! node-pre-gyp ERR! stack at ChildProcess. (/usr/src/app/node_modules/@mapbox/node-pre-gyp/lib/util/compile.js:89:23)
npm ERR! node-pre-gyp ERR! stack at ChildProcess.emit (node:events:513:28)
npm ERR! node-pre-gyp ERR! stack at maybeClose (node:internal/child_process:1091:16)
npm ERR! node-pre-gyp ERR! stack at ChildProcess._handle.onexit (node:internal/child_process:302:5)
npm ERR! node-pre-gyp ERR! System Linux 5.10.162+
npm ERR! node-pre-gyp ERR! command "/usr/local/bin/node" "/usr/src/app/node_modules/.bin/node-pre-gyp" "install" "--fallback-to-build" "--update-binary"
npm ERR! node-pre-gyp ERR! cwd /usr/src/app/node_modules/canvas
npm ERR! node-pre-gyp ERR! node -v v18.16.0
npm ERR! node-pre-gyp ERR! node-pre-gyp -v v1.0.10
npm ERR! node-pre-gyp ERR! not ok
npm verb exit 1
npm verb unfinished npm timer reify 1682003380890
npm verb unfinished npm timer reify:build 1682003407675
npm verb unfinished npm timer build 1682003407678
npm verb unfinished npm timer build:deps 1682003407680
npm verb unfinished npm timer build:run:install 1682003407776
npm verb unfinished npm timer build:run:install:node_modules/canvas 1682003407776
npm verb unfinished npm timer build:run:install:node_modules/puppeteer 1682003407827
npm verb unfinished npm timer build:run:install:node_modules/sharp 1682003407849
npm verb code 1
npm ERR! A complete log of this run can be found in:
npm ERR! /root/.npm/_logs/2023-04-20T15_09_40_833Z-debug-0.log
The command '/bin/sh -c npm install canvas --omit=optional --target_libc=musl --build-from-source --verbose' returned a non-zero code: 1
```
## Steps to Reproduce
```Dockerfile
FROM node:18.16-alpine
COPY --chown=root:root ./ ./
RUN apk add postgresql-client git udev chromium nss freetype harfbuzz ttf-freefont ca-certificates \
build-base g++ cairo-dev jpeg-dev pango-dev giflib-dev libpng-dev librsvg-dev pkgconfig \
libffi-dev openssl-dev
RUN npm install -g node-gyp
RUN npm install canvas --omit=optional --target_libc=musl --build-from-source
```
## Your Environment
* Version of node-canvas (output of `npm list canvas` or `yarn list canvas`): canvas@2.11.2
* Environment (e.g. node 4.2.0 on Mac OS X 10.8): node:18.16-alpine in Gitlab CI
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.