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

Cannot build @parcel/watcher #212

Open
darkbasic opened this issue Mar 14, 2023 · 9 comments
Open

Cannot build @parcel/watcher #212

darkbasic opened this issue Mar 14, 2023 · 9 comments
Labels
bug Something isn't working

Comments

@darkbasic
Copy link
Contributor

$ yarn
yarn install v1.22.19
info No lockfile found.
[1/4] Resolving packages...
[2/4] Fetching packages...
[3/4] Linking dependencies...
[4/4] Building fresh packages...
[-/2] ⡀ waiting...
error /home/niko/devel/beach/server/node_modules/@parcel/watcher: Command failed.
Exit code: 1
Command: node-gyp-build
Arguments: 
Directory: /home/niko/devel/beach/server/node_modules/@parcel/watcher
Output:
gyp info it worked if it ends with ok
gyp info using [email protected]
gyp info using [email protected] | linux | ppc64
gyp info find Python using Python version 3.10.10 found at "/usr/lib/python-exec/python3.10/python3"
gyp WARN read config.gypi ENOENT: no such file or directory, open '/usr/include/electron-22/node/include/node/config.gypi'
gyp info spawn /usr/lib/python-exec/python3.10/python3
gyp info spawn args [
gyp info spawn args   '/home/niko/.nvm/versions/node/v18.15.0/lib/node_modules/npm/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/niko/devel/beach/server/node_modules/@parcel/watcher/build/config.gypi',
gyp info spawn args   '-I',
gyp info spawn args   '/home/niko/.nvm/versions/node/v18.15.0/lib/node_modules/npm/node_modules/node-gyp/addon.gypi',
gyp info spawn args   '-I',
gyp info spawn args   '/usr/include/electron-22/node/common.gypi',
gyp info spawn args   '-Dlibrary=shared_library',
gyp info spawn args   '-Dvisibility=default',
gyp info spawn args   '-Dnode_root_dir=/usr/include/electron-22/node',
gyp info spawn args   '-Dnode_gyp_dir=/home/niko/.nvm/versions/node/v18.15.0/lib/node_modules/npm/node_modules/node-gyp',
gyp info spawn args   '-Dnode_lib_file=/usr/include/electron-22/node/$(Configuration)/node.lib',
gyp info spawn args   '-Dmodule_root_dir=/home/niko/devel/beach/server/node_modules/@parcel/watcher',
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 ]
gyp info spawn make
gyp info spawn args [ 'BUILDTYPE=Release', '-C', 'build' ]
make: Entering directory '/home/niko/devel/beach/server/node_modules/@parcel/watcher/build'
  CC(target) Release/obj.target/nothing/../../node-addon-api/nothing.o
rm -f Release/obj.target/../../node-addon-api/nothing.a Release/obj.target/../../node-addon-api/nothing.a.ar-file-list; mkdir -p `dirname Release/obj.target/../../node-addon-api/nothing.a`
ar crs Release/obj.target/../../node-addon-api/nothing.a @Release/obj.target/../../node-addon-api/nothing.a.ar-file-list
  COPY Release/nothing.a
  CXX(target) Release/obj.target/watcher/src/binding.o
In file included from ../src/binding.cc:3:
../../../node-addon-api/napi.h:4:10: fatal error: node_api.h: No such file or directory
    4 | #include <node_api.h>
      |          ^~~~~~~~~~~~
compilation terminated.
make: *** [watcher.target.mk:135: Release/obj.target/watcher/src/binding.o] Error 1
make: Leaving directory '/home/niko/devel/beach/server/node_modules/@parcel/watcher/build'
gyp ERR! build error 
gyp ERR! stack Error: `make` failed with exit code: 2
gyp ERR! stack     at ChildProcess.onExit (/home/niko/.nvm/versions/node/v18.15.0/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:203:23)
gyp ERR! stack     at ChildProcess.emit (node:events:513:28)
gyp ERR! stack     at ChildProcess._handle.onexit (node:internal/child_process:291:12)
gyp ERR! System Linux 6.2.6-gentoo-dist
gyp ERR! command "/home/niko/.nvm/versions/node/v18.15.0/bin/node" "/home/niko/.nvm/versions/node/v18.15.0/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /home/niko/devel/beach/server/node_modules/@parcel/watcher
gyp ERR! node -v v18.15.0
gyp ERR! node-gyp -v v9.3.1
gyp ERR! not ok
talos2 ~ # find /mnt/root/ | grep "node_api.h"
/mnt/root/usr/include/node/node_api.h
/mnt/root/usr/include/electron-19/node/node_api.h
/mnt/root/usr/include/electron-22/node/node_api.h

talos2 ~ # find /mnt/root/ | grep "config.gypi"
/mnt/root/usr/include/node/config.gypi
/mnt/root/usr/include/electron-19/node/config.gypi
/mnt/root/usr/include/electron-22/node/config.gypi
/mnt/root/usr/lib64/node_modules/npm/node_modules/node-gyp/lib/create-config-gypi.js
/mnt/root/usr/lib64/electron-19/node_modules/npm/node_modules/node-gyp/lib/create-config-gypi.js
/mnt/root/usr/lib64/electron-19/node_modules/npm/node_modules/node-gyp/test/fixtures/nodedir/include/node/config.gypi
/mnt/root/usr/lib64/electron-19/node_modules/npm/node_modules/node-gyp/test/test-create-config-gypi.js
/mnt/root/usr/lib64/electron-22/node_modules/npm/node_modules/node-gyp/test/fixtures/nodedir/include/node/config.gypi
/mnt/root/usr/lib64/electron-22/node_modules/npm/node_modules/node-gyp/test/test-create-config-gypi.js
/mnt/root/usr/lib64/electron-22/node_modules/npm/node_modules/node-gyp/lib/create-config-gypi.js

talos2 ~ # mkdir /mnt/root/usr/include/electron-22/node/include

talos2 ~ # ln -s /mnt/root/usr/include/electron-22/node /mnt/root/usr/include/electron-22/node/include/node

Symlinking /usr/include/electron-22/node/include/node to /usr/include/electron-22/node did the trick.
A few months ago it used to work, no idea what changed.

@darkbasic darkbasic added the bug Something isn't working label Mar 14, 2023
@PF4Public
Copy link
Owner

PF4Public commented Mar 14, 2023

'-Dnode_gyp_dir=/home/niko/.nvm/versions/node/v18.15.0/lib/node_modules/npm/node_modules/node-gyp',

Why is it there? Should't it be in node's dir of electron?

@darkbasic
Copy link
Contributor Author

It's because of nvm: I use it to co-install multiple versions of node (gentoo doesn't support slotting for node.js).

@PF4Public
Copy link
Owner

That should be the answer to build failure

@darkbasic
Copy link
Contributor Author

With system node it fails with a completely different error:

$ yarn
yarn install v1.22.19
[1/4] Resolving packages...
[2/4] Fetching packages...
[3/4] Linking dependencies...
[4/4] Building fresh packages...
[-/2] ⢀ waiting...
error /home/niko/devel/beach/server/node_modules/@parcel/watcher: Command failed.
Exit code: 1
Command: node-gyp-build
Arguments: 
Directory: /home/niko/devel/beach/server/node_modules/@parcel/watcher
Output:
node:events:491
      throw er; // Unhandled 'error' event
      ^

Error: spawn node-gyp ENOENT
    at ChildProcess._handle.onexit (node:internal/child_process:283:19)
    at onErrorNT (node:internal/child_process:476:16)
    at process.processTicksAndRejections (node:internal/process/task_queues:82:21)
Emitted 'error' event on ChildProcess instance at:
    at ChildProcess._handle.onexit (node:internal/child_process:289:12)
    at onErrorNT (node:internal/child_process:476:16)
    at process.processTicksAndRejections (node:internal/process/task_queues:82:21) {
  errno: -2,
  code: 'ENOENT',
  syscall: 'spawn node-gyp',
  path: 'node-gyp',
  spawnargs: [ 'rebuild' ]
}

Node.js v18.14.2

I don't think I ever used system node to build it in the past.

@PF4Public
Copy link
Owner

If it wants to build electron module it should use electron and electron's node and electron's node-gyp, nothing else.

@PF4Public
Copy link
Owner

So, have you managed to make it work?

@darkbasic
Copy link
Contributor Author

darkbasic commented Apr 6, 2023

I still have to figure out the best way to handle this: @parcel/watcher is being pulled in by lots of projects including non-electron ones and it makes no sense to use Electron's node in such projects (it might not even be compatible). I don't think there is a way to selectively use Electron's node just for the build, but anyway building against a different node version works fine, you just need to symlink /usr/include/electron-22/node/include/node to /usr/include/electron-22/node.
Not sure if it's our fault and the electron ebuild should provide such symlink or if it's @parcel/watcher's fault (you usually realy on binaries on x86 instead of building it). I still have to dive deeper into this, but it's probably worth trying to build it on x86 with the electron's binary package and/or filing a bug at @parcel/watcher to ask about their build process.

@darkbasic
Copy link
Contributor Author

@PF4Public please have a look at this microsoft/vscode#182743 (comment)

@PF4Public
Copy link
Owner

I've moved /usr/include/electron-24/node/ into /usr/include/electron-24/node/include/node/ and tried building element and vscode and they both succeeded, so maybe those includes should go into that folder at the first place? @darkbasic Could you verify that nothing is expecting includes to be in /usr/include/electron-24/node/, so that we can install them straight to /usr/include/electron-24/node/include/node/?

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

2 participants