parcel-bundler / watcher

👀 A native C++ Node module for querying and subscribing to filesystem events
MIT License
659 stars 45 forks source link

node-gyp build failure when trying to build via cmake #104

Open tytremblay opened 2 years ago

tytremblay commented 2 years ago

This is occuring on our build server running a clean docker image of Ubuntu 20.04 and building our webapp as part of a cmake project. @parcel/watcher fails to compile, showing this error.

npm ERR! path /builds/realtime-robotics/rapidplan/rapidplan_2.0.4-182-g64969e95a/build/rtr_web_tools/build/node_modules/@parcel/watcher
npm ERR! command failed
npm ERR! command sh -c node-gyp-build
npm ERR! make[8]: Entering directory '/builds/realtime-robotics/rapidplan/rapidplan_2.0.4-182-g64969e95a/build/rtr_web_tools/build/node_modules/@parcel/watcher'
npm ERR!   CC(target) Release/obj.target/nothing/../../node-addon-api/nothing.o
npm ERR!   AR(target) Release/obj.target/../../node-addon-api/nothing.a
npm ERR!   COPY Release/nothing.a
npm ERR!   CXX(target) Release/obj.target/watcher/src/binding.o
npm ERR!   CXX(target) Release/obj.target/watcher/src/Watcher.o
npm ERR!   CXX(target) Release/obj.target/watcher/src/Backend.o
npm ERR!   CXX(target) Release/obj.target/watcher/src/DirTree.o
npm ERR!   CXX(target) Release/obj.target/watcher/src/watchman/BSER.o
npm ERR!   CXX(target) Release/obj.target/watcher/src/watchman/WatchmanBackend.o
npm ERR!   CXX(target) Release/obj.target/watcher/src/shared/BruteForceBackend.o
npm ERR!   CXX(target) Release/obj.target/watcher/src/linux/InotifyBackend.o
npm ERR!   CXX(target) Release/obj.target/watcher/src/unix/legacy.o
npm ERR! make[8]: Leaving directory '/builds/realtime-robotics/rapidplan/rapidplan_2.0.4-182-g64969e95a/build/rtr_web_tools/build/node_modules/@parcel/watcher/build'
npm ERR! make[8]: warning: jobserver unavailable: using -j1.  Add '+' to parent make rule.
npm ERR! ../src/linux/InotifyBackend.cc:60:3: warning: ignoring return value of function declared with 'warn_unused_result' attribute [-Wunused-result]
npm ERR!   write(mPipe[1], "X", 1);
npm ERR!   ^~~~~ ~~~~~~~~~~~~~~~~
npm ERR! 1 warning generated.
npm ERR! In file included from ../src/unix/legacy.cc:12:
npm ERR! /usr/include/x86_64-linux-gnu/sys/stat.h:453:8: error: exception specification in declaration does not match previous declaration
npm ERR! __NTH (stat (const char *__path, struct stat *__statbuf))
npm ERR!        ^
npm ERR! /usr/include/x86_64-linux-gnu/sys/stat.h:213:28: note: previous declaration is here
npm ERR! extern int __REDIRECT_NTH (stat, (const char *__restrict __file,
npm ERR!                            ^
npm ERR! /usr/include/x86_64-linux-gnu/sys/stat.h:460:8: error: exception specification in declaration does not match previous declaration
npm ERR! __NTH (lstat (const char *__path, struct stat *__statbuf))
npm ERR!        ^
npm ERR! /usr/include/x86_64-linux-gnu/sys/stat.h:263:28: note: previous declaration is here
npm ERR! extern int __REDIRECT_NTH (lstat,
npm ERR!                            ^
npm ERR! /usr/include/x86_64-linux-gnu/sys/stat.h:467:8: error: exception specification in declaration does not match previous declaration
npm ERR! __NTH (fstat (int __fd, struct stat *__statbuf))
npm ERR!        ^

Snip a bunch of similar errors


npm ERR! __NTH (getdomainname (char *__buf, size_t __buflen))
npm ERR!        ^
npm ERR! /usr/include/unistd.h:895:12: note: previous declaration is here
npm ERR! extern int getdomainname (char *__name, size_t __len)
npm ERR!            ^
npm ERR! fatal error: too many errors emitted, stopping now [-ferror-limit=]
npm ERR! 20 errors generated.
npm ERR! make[8]: *** [watcher.target.mk:130: Release/obj.target/watcher/src/unix/legacy.o] Error 1
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/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:194:23)
npm ERR! gyp ERR! stack     at ChildProcess.emit (node:events:527:28)
npm ERR! gyp ERR! stack     at Process.ChildProcess._handle.onexit (node:internal/child_process:291:12)
npm ERR! gyp ERR! System Linux 5.11.0-1022-aws
npm ERR! gyp ERR! command "/usr/bin/node" "/usr/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
npm ERR! gyp ERR! cwd /builds/realtime-robotics/rapidplan/rapidplan_2.0.4-182-g64969e95a/build/rtr_web_tools/build/node_modules/@parcel/watcher
npm ERR! gyp ERR! node -v v16.15.1
npm ERR! gyp ERR! node-gyp -v v9.0.0
npm ERR! gyp ERR! not ok````
tytremblay commented 2 years ago

Any thoughts on why node-gyp-build is not finding the linux-x64 prebuild here?

mischnic commented 2 years ago

Not sure about either of these problems. I just tried it in a rather fresh Ubuntu 20.04 VM: it reused the prebuild and was also able to compile it locally.

This code might be related regarding exceptions (though I don't know what specific error was the motivation): https://github.com/parcel-bundler/watcher/blob/caf372c41abff401a60dde698891631e3387ee77/src/unix/legacy.cc#L3-L7

realtime-neil commented 2 years ago

How might one force node-gyp-build to fail unless the prebuild is found and used? Apparently, I don't understand the subtlety around PREBUILDS_ONLY because that's not working for me. Or, rather, us.

ruizmarc commented 2 years ago

I'm having the same problem with Linux Alpine. Since I'm using parcel/watcher 2.0.4, prebuild is not found and tries to compile locally, but failing afterall

Belco90 commented 2 years ago

I'm having the same problem with Linux Alpine. Since I'm using parcel/watcher 2.0.4, prebuild is not found and tries to compile locally, but failing afterall

Running into the same issue. Shouldn't node-gyp be an explicit dependency of this package?

shellscape commented 1 year ago

Running into this on Github Actions with Ubuntu