Skip to content
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

Fix node-gyp failing to build canvas #5202

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Conversation

skrat
Copy link

@skrat skrat commented Jun 14, 2022

So there is a commonly use node (npm) package called "canvas", which uses node-gyp to bind to cairo (2D canvas drawing library). And I assume this is useful outside of this particular case. node-gyp (run by yarn install or npm install) needs access to /usr/share/pkgconfig otherwise it fails to buold the native extensions.

So it's either this proposed change, or it can be move to yarn.profile or npm.profile. I'm not sure it will work when moved to node-gyp.profile as that one is invoked as a subprocess.

It can also, instead of including build-systems-common.profile just whitelist /usr/share/pkgconfig.

So there is a commonly use node (npm) package called "canvas", which uses node-gyp to bind to cairo (2D canvas drawing library). And I assume this is useful outside of this particular case. node-gyp (run by `yarn install` or `npm install`) needs access to `/usr/share/pkgconfig` otherwise it fails to buold the native extensions.

So it's either this proposed change, or it can be move to `yarn.profile` or `npm.profile`. I'm not sure it will work when moved to `node-gyp.profile` as that one is invoked as a subprocess.

It can also, instead of including `build-systems-common.profile` just whitelist `/usr/share/pkgconfig`.
@@ -67,6 +67,7 @@ include disable-xdg.inc
whitelist /usr/share/doc/node
whitelist /usr/share/nvm
whitelist /usr/share/systemtap/tapset/node.stp
include build-systems-common.profile
Copy link
Collaborator

@rusty-snake rusty-snake Jun 14, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It can also, instead of including build-systems-common.profile just whitelist /usr/share/pkgconfig.

Likely easier than the above.

Copy link
Collaborator

@glitsj16 glitsj16 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's considerable overlap between nodejs-common and build-systems-common. IMO it's asking for trouble by including the latter in the former. I'll do some testing shortly but adding whitelist /usr/share/pkgconfig to nodejs-common.profile is the cleaner option.

Fix node-gyp failing to build canvas

Do you have a reproducer? Or a more detailed log of what is actually failing?

@skrat
Copy link
Author

skrat commented Jun 22, 2022

Any yarn npm project that has canvas as a dependency. I'm fine with just whitelist /usr/share/pkgconfig. Should I redo?

~/W/r/rwdom master• ↑2 1.1s $ yarn install
yarn install v1.22.19
[1/4] Resolving packages...
[2/4] Fetching packages...
[3/4] Linking dependencies...
[4/4] Building fresh packages...
[-/3] ⢀ waiting...
[-/3] ⢀ waiting...
error /home/skrat/Workspace/renoworks/rwdom/node_modules/canvas: Command failed.
Exit code: 1
Command: node-pre-gyp install --fallback-to-build
Arguments:
Directory: /home/skrat/Workspace/renoworks/rwdom/node_modules/canvas
Output:
node-pre-gyp info it worked if it ends with ok
node-pre-gyp info using [email protected]
node-pre-gyp info using [email protected] | linux | x64
node-pre-gyp info check checked for "/home/skrat/Workspace/renoworks/rwdom/node_modules/canvas/build/Release/canvas.node" (not found)
node-pre-gyp http GET https://github.com/Automattic/node-canvas/releases/download/v2.9.1/canvas-v2.9.1-node-v108-linux-glibc-x64.tar.gz
node-pre-gyp ERR! install response status 404 Not Found on https://github.com/Automattic/node-canvas/releases/download/v2.9.1/canvas-v2.9.1-node-v108-linux-glibc-x64.tar.gz
node-pre-gyp WARN Pre-built binaries not installable for [email protected] and [email protected] (node-v108 ABI, glibc) (falling back to source compile with node-gyp)
node-pre-gyp WARN Hit error response status 404 Not Found on https://github.com/Automattic/node-canvas/releases/download/v2.9.1/canvas-v2.9.1-node-v108-linux-glibc-x64.tar.gz
gyp info it worked if it ends with ok
gyp info using [email protected]
gyp info using [email protected] | linux | x64
gyp info ok
gyp info it worked if it ends with ok
gyp info using [email protected]
gyp info using [email protected] | linux | x64
gyp info find Python using Python version 3.10.5 found at "/usr/bin/python3"
gyp http GET https://nodejs.org/download/release/v18.3.0/node-v18.3.0-headers.tar.gz
gyp http 200 https://nodejs.org/download/release/v18.3.0/node-v18.3.0-headers.tar.gz
gyp http GET https://nodejs.org/download/release/v18.3.0/SHASUMS256.txt
gyp http 200 https://nodejs.org/download/release/v18.3.0/SHASUMS256.txt
gyp info spawn /usr/bin/python3
gyp info spawn args [
gyp info spawn args   '/usr/lib/node_modules/node-gyp/gyp/gyp_main.py',
gyp info spawn args   'binding.gyp',
gyp info spawn args   '-f',
gyp info spawn args   'make',
gyp info spawn args   '-I',
gyp info spawn args   '/home/skrat/Workspace/renoworks/rwdom/node_modules/canvas/build/config.gypi',
gyp info spawn args   '-I',
gyp info spawn args   '/usr/lib/node_modules/node-gyp/addon.gypi',
gyp info spawn args   '-I',
gyp info spawn args   '/home/skrat/.cache/node-gyp/18.3.0/include/node/common.gypi',
gyp info spawn args   '-Dlibrary=shared_library',
gyp info spawn args   '-Dvisibility=default',
gyp info spawn args   '-Dnode_root_dir=/home/skrat/.cache/node-gyp/18.3.0',
gyp info spawn args   '-Dnode_gyp_dir=/usr/lib/node_modules/node-gyp',
gyp info spawn args   '-Dnode_lib_file=/home/skrat/.cache/node-gyp/18.3.0/<(target_arch)/node.lib',
gyp info spawn args   '-Dmodule_root_dir=/home/skrat/Workspace/renoworks/rwdom/node_modules/canvas',
gyp info spawn args   '-Dnode_engine=v8',
gyp info spawn args   '--depth=.',
gyp info spawn args   '--no-parallel',
gyp info spawn args   '--generator-output',
gyp info spawn args   'build',
gyp info spawn args   '-Goutput_dir=.'
gyp info spawn args ]
Package xproto was not found in the pkg-config search path.
Perhaps you should add the directory containing `xproto.pc'
to the PKG_CONFIG_PATH environment variable
Package 'xproto', required by 'x11', not found
Package 'kbproto', required by 'x11', not found
Package 'xextproto', required by 'xext', not found
Package 'xproto', required by 'xrender', not found
Package 'renderproto', required by 'xrender', not found
Package 'xproto', required by 'x11', not found
Package 'kbproto', required by 'x11', not found
Package 'xproto', required by 'xau', not found
Package 'xproto', required by 'xdmcp', not found
Package 'xproto', required by 'xau', not found
Package 'xproto', required by 'xdmcp', not found
Package 'xproto', required by 'xau', not found
Package 'xproto', required by 'xdmcp', not found
gyp: Call to 'pkg-config cairo --cflags-only-I | sed s/-I//g' returned exit status 0 while in binding.gyp. while trying to load binding.gyp
gyp ERR! configure error
gyp ERR! stack Error: `gyp` failed with exit code: 1
gyp ERR! stack     at ChildProcess.onCpExit (/usr/lib/node_modules/node-gyp/lib/configure.js:261:16)
gyp ERR! stack     at ChildProcess.emit (node:events:527:28)
gyp ERR! stack     at ChildProcess._handle.onexit (node:internal/child_process:291:12)
gyp ERR! System Linux 5.18.3-zen1-1-zen
gyp ERR! command "/usr/bin/node" "/usr/lib/node_modules/node-gyp/bin/node-gyp.js" "configure" "--fallback-to-build" "--module=/home/skrat/Workspace/renoworks/rwdom/node_modules/canvas/build/Release/canvas.node" "--module_name=canvas" "--module_path=/home/skrat/Workspace/renoworks/rwdom/node_modules/canvas/build/Release" "--napi_version=8" "--node_abi_napi=napi" "--napi_build_version=0" "--node_napi_label=node-v108"
gyp ERR! cwd /home/skrat/Workspace/renoworks/rwdom/node_modules/canvas
gyp ERR! node -v v18.3.0
gyp ERR! node-gyp -v v9.0.0
gyp ERR! not ok
node-pre-gyp ERR! build error
node-pre-gyp ERR! stack Error: Failed to execute 'node-gyp configure --fallback-to-build --module=/home/skrat/Workspace/renoworks/rwdom/node_modules/canvas/build/Release/canvas.node --module_name=canvas --module_path=/home/skrat/Workspace/renoworks/rwdom/node_modules/canvas/build/Release --napi_version=8 --node_abi_napi=napi --napi_build_version=0 --node_napi_label=node-v108' (1)
node-pre-gyp ERR! stack     at ChildProcess.<anonymous> (/home/skrat/Workspace/renoworks/rwdom/node_modules/@mapbox/node-pre-gyp/lib/util/compile.js:89:23)
node-pre-gyp ERR! stack     at ChildProcess.emit (node:events:527:28)
node-pre-gyp ERR! stack     at maybeClose (node:internal/child_process:1090:16)
node-pre-gyp ERR! stack     at ChildProcess._handle.onexit (node:internal/child_process:302:5)
node-pre-gyp ERR! System Linux 5.18.3-zen1-1-zen
node-pre-gyp ERR! command "/usr/bin/node" "/home/skrat/Workspace/renoworks/rwdom/node_modules/canvas/node_modules/.bin/node-pre-gyp" "install" "--fallback-to-build"
node-pre-gyp ERR! cwd /home/skrat/Workspace/renoworks/rwdom/node_modules/canvas
node-pre-gyp ERR! node -v v18.3.0
node-pre-gyp ERR! node-pre-gyp -v v1.0.7
node-pre-gyp ERR! not ok
Failed to execute 'node-gyp configure --fallback-to-build --module=/home/skrat/Workspace/renoworks/rwdom/node_modules/canvas/build/Release/canvas.node --module_name=canvas --module_path=/home/skrat/Workspace/renoworks/rwdom/node_modules/canvas/build/Release --napi_versi

@rusty-snake
Copy link
Collaborator

I'm fine with just whitelist /usr/share/pkgconfig. Should I redo?

Yes

@glitsj16
Copy link
Collaborator

Any yarn npm project that has canvas as a dependency. I'm fine with just whitelist /usr/share/pkgconfig. Should I redo?

If you mean redo the PR to add whitelist /usr/share/pkgconfig to nodejs-common.profile instead of what you have now: yes please do :-) You might need to rebase for the CI check.

Copy link
Collaborator

@glitsj16 glitsj16 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you redo? Add whitelist /usr/share/pkgconfig and we can bring this in.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants