WiseLibs / better-sqlite3

The fastest and simplest library for SQLite3 in Node.js.
MIT License
5.46k stars 396 forks source link

Installation error: No prebuilt binaries found (target=20.3.1 runtime=node arch=arm64 libc= platform=darwin) #1027

Open 0xOlias opened 1 year ago

0xOlias commented 1 year ago

I'm can't install better-sqlite3 using the prebuilt binaries on my local machine. My versions are very similar to #1022, but I'm using pnpm.

Here's the original error message:

kevinkoste core % pnpm add better-sqlite3 
 WARN  deprecated string-similarity@4.0.4: Package no longer supported. Contact Support at https://www.npmjs.com/support for more info.
../..                                    |  +30 +++
../..                                    | Progress: resolved 800, reused 738, downloaded 0, added 0, done
../../node_modules/.pnpm/better-sqlite3@8.4.0/node_modules/better-sqlite3: Running install script...
 ELIFECYCLE  Command failed.
kevinkoste core % 

I suspected that this was not the full story, so I ran it again using pnpm add better-sqlite3 --reporter ndjson and found the actual error:

{"time":1687901236730,"hostname":"Kevins-MacBook-Pro.local","pid":83779,"level":"debug","name":"pnpm:lifecycle","depPath":"/better-sqlite3/8.4.0","optional":false,"script":"prebuild-install || node-gyp rebuild --release","stage":"install","wd":"/Users/kevinkoste/workspace/ponder/node_modules/.pnpm/better-sqlite3@8.4.0/node_modules/better-sqlite3"}
{"time":1687901236994,"hostname":"Kevins-MacBook-Pro.local","pid":83779,"level":"debug","name":"pnpm:lifecycle","depPath":"/better-sqlite3/8.4.0","line":"prebuild-install warn install No prebuilt binaries found (target=20.3.1 runtime=node arch=arm64 libc= platform=darwin)","stage":"install","stdio":"stderr","wd":"/Users/kevinkoste/workspace/ponder/node_modules/.pnpm/better-sqlite3@8.4.0/node_modules/better-sqlite3"}
{"time":1687901236996,"hostname":"Kevins-MacBook-Pro.local","pid":83779,"level":"debug","name":"pnpm:lifecycle","depPath":"/better-sqlite3/8.4.0","line":"sh: node-gyp: command not found","stage":"install","stdio":"stderr","wd":"/Users/kevinkoste/workspace/ponder/node_modules/.pnpm/better-sqlite3@8.4.0/node_modules/better-sqlite3"}
{"time":1687901236997,"hostname":"Kevins-MacBook-Pro.local","pid":83779,"level":"error","name":"pnpm","code":"ELIFECYCLE","errno":"ENOENT","syscall":"spawn","file":"sh","pkgid":"better-sqlite3@8.4.0","stage":"install","script":"prebuild-install || node-gyp rebuild --release","pkgname":"better-sqlite3","name":"pnpm","err":{"name":"pnpm","message":"better-sqlite3@8.4.0 install: `prebuild-install || node-gyp rebuild --release`\nspawn ENOENT","code":"ELIFECYCLE","stack":"pnpm: better-sqlite3@8.4.0 install: `prebuild-install || node-gyp rebuild --release`\nspawn ENOENT\n    at ChildProcess.<anonymous> (/snapshot/dist/pnpm.cjs)\n    at ChildProcess.emit (events.js:400:28)\n    at maybeClose (internal/child_process.js:1088:16)\n    at Socket.<anonymous> (internal/child_process.js:446:11)\n    at Socket.emit (events.js:400:28)\n    at Pipe.<anonymous> (net.js:686:12)"}}
prebuild-install warn install No prebuilt binaries found (target=20.3.1 runtime=node arch=arm64 libc= platform=darwin)

Any idea why it's not finding the prebuilt binary? My understanding is that there is a prebuilt binary matching (target=20.3.1 runtime=node arch=arm64 libc= platform=darwin) for better-sqlite3@8.4.0.

neoxpert commented 1 year ago

Just out of curiosity: Does it work if you use npm / yarn? Just to remove pnpm from the checklist.

Regarding the log lines it does not look like an issue with better-sqlite3 itself but a problem on the target machine or somewhere in the involved utility libs for looking up / loading the prebuilt binaries. I'm not that used to the MacOS eco system, but "code":"ELIFECYCLE","errno":"ENOENT","syscall":"spawn","file":"sh" looks like something is not working as it should. ENOENT hints that something was not found / does not exist in the file system.

Also it looks like that node-gyp is missing on your machine as the 3 log line states sh: node-gyp: command not found. What does pnpm list "node-gyp*" give as output? Have you tried installing it manually? Actually there is an open issue about pnpm and node-gyp https://github.com/pnpm/pnpm/issues/4347.

0xOlias commented 1 year ago

Thanks for the response. I did some more digging:

  1. pnpm list "node-gyp*" indeed returned nothing. I tried installed node-gyp manually and then was able to install better-sqlite3@8.4.0 successfully. This seems to confirm the pnpm issue you linked above.
  2. Interestingly, I was able to install better-sqlite3@7.6.2 successfully before installing node-gyp. I can't tell from the pnpm logs whether it's finding the prebuilt binary in that case or building from source. My guess is that it's building from source.
  3. I am able to install both aforementioned versions of better-sqlite3 using npm. Again, I can't tell if it's using the prebuilt binary there or building from source. It seems like it's building from source (also takes 19s to install).
  4. Installation with Yarn works on Node 18, but not Node 20. It's clear from the logs that it's building from source in both cases.
    yarn install better-sqlite@^8.4.0 Node 18 logs (success)
[4/4] 🔨  Building fresh packages...
[1/2] ⡀ better-sqlite3
verbose 19.852559167 prebuild-install warn install No prebuilt binaries found (target=18.16.1 runtime=node arch=arm64 libc= platform=darwin)

> better-sqlite3@7.6.2 build-release
> node-gyp rebuild --release

gyp info it worked if it ends with ok
gyp info using node-gyp@9.3.1
gyp info using node@18.16.1 | darwin | arm64
gyp info find Python using Python version 3.9.6 found at "/Library/Developer/CommandLineTools/usr/bin/python3"
gyp info spawn /Library/Developer/CommandLineTools/usr/bin/python3
gyp info spawn args [
gyp info spawn args   '/Users/kevinkoste/.nvm/versions/node/v18.16.1/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   '/Users/kevinkoste/workspace/tmp/npm-test/node_modules/better-sqlite3/build/config.gypi',
gyp info spawn args   '-I',
gyp info spawn args   '/Users/kevinkoste/.nvm/versions/node/v18.16.1/lib/node_modules/npm/node_modules/node-gyp/addon.gypi',
gyp info spawn args   '-I',
gyp info spawn args   '/Users/kevinkoste/Library/Caches/node-gyp/18.16.1/include/node/common.gypi',
gyp info spawn args   '-Dlibrary=shared_library',
gyp info spawn args   '-Dvisibility=default',
gyp info spawn args   '-Dnode_root_dir=/Users/kevinkoste/Library/Caches/node-gyp/18.16.1',
gyp info spawn args   '-Dnode_gyp_dir=/Users/kevinkoste/.nvm/versions/node/v18.16.1/lib/node_modules/npm/node_modules/node-gyp',
gyp info spawn args   '-Dnode_lib_file=/Users/kevinkoste/Library/Caches/node-gyp/18.16.1/<(target_arch)/node.lib',
gyp info spawn args   '-Dmodule_root_dir=/Users/kevinkoste/workspace/tmp/npm-test/node_modules/better-sqlite3',
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' ]
  TOUCH ba23eeee118cd63e16015df367567cb043fed872.intermediate
  ACTION deps_sqlite3_gyp_locate_sqlite3_target_copy_builtin_sqlite3 ba23eeee118cd63e16015df367567cb043fed872.intermediate
  TOUCH Release/obj.target/deps/locate_sqlite3.stamp
  CC(target) Release/obj.target/sqlite3/gen/sqlite3/sqlite3.o
  LIBTOOL-STATIC Release/sqlite3.a
  CXX(target) Release/obj.target/better_sqlite3/src/better_sqlite3.o
./src/objects/database.lzz:180:21: warning: variable 'status' set but not used [-Wunused-but-set-variable]
                int status = sqlite3_db_config(db_handle, SQLITE_DBCONFIG_ENABLE_LOAD_EXTENSION, 1, NULL);
                    ^
1 warning generated.
  SOLINK_MODULE(target) Release/better_sqlite3.node
  CC(target) Release/obj.target/test_extension/deps/test_extension.o
  SOLINK_MODULE(target) Release/test_extension.node
rm ba23eeee118cd63e16015df367567cb043fed872.intermediate
success Saved lockfile.
success Saved 1 new dependency.
info Direct dependencies
└─ better-sqlite3@8.4.0
info All dependencies
└─ better-sqlite3@8.4.0
✨  Done in 20.12s.

yarn install better-sqlite@^8.4.0 Node 20 logs (failure) ``` [4/4] 🔨 Building fresh packages... [1/2] ⠠ better-sqlite3 verbose 18.645091334 Error: /Users/kevinkoste/workspace/tmp/npm-test/node_modules/@ponder/core/node_modules/better-sqlite3: Command failed. Exit code: 1 Command: prebuild-install || npm run build-release Arguments: Directory: /Users/kevinkoste/workspace/tmp/npm-test/node_modules/@ponder/core/node_modules/better-sqlite3 Output: prebuild-install warn install No prebuilt binaries found (target=20.3.1 runtime=node arch=arm64 libc= platform=darwin) > better-sqlite3@7.6.2 build-release > node-gyp rebuild --release gyp info it worked if it ends with ok gyp info using node-gyp@9.3.1 gyp info using node@20.3.1 | darwin | arm64 gyp info find Python using Python version 3.9.6 found at "/Library/Developer/CommandLineTools/usr/bin/python3" gyp info spawn /Library/Developer/CommandLineTools/usr/bin/python3 gyp info spawn args [ gyp info spawn args '/Users/kevinkoste/.nvm/versions/node/v20.3.1/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 '/Users/kevinkoste/workspace/tmp/npm-test/node_modules/@ponder/core/node_modules/better-sqlite3/build/config.gypi', gyp info spawn args '-I', gyp info spawn args '/Users/kevinkoste/.nvm/versions/node/v20.3.1/lib/node_modules/npm/node_modules/node-gyp/addon.gypi', gyp info spawn args '-I', gyp info spawn args '/Users/kevinkoste/Library/Caches/node-gyp/20.3.1/include/node/common.gypi', gyp info spawn args '-Dlibrary=shared_library', gyp info spawn args '-Dvisibility=default', gyp info spawn args '-Dnode_root_dir=/Users/kevinkoste/Library/Caches/node-gyp/20.3.1', gyp info spawn args '-Dnode_gyp_dir=/Users/kevinkoste/.nvm/versions/node/v20.3.1/lib/node_modules/npm/node_modules/node-gyp', gyp info spawn args '-Dnode_lib_file=/Users/kevinkoste/Library/Caches/node-gyp/20.3.1/<(target_arch)/node.lib', gyp info spawn args '-Dmodule_root_dir=/Users/kevinkoste/workspace/tmp/npm-test/node_modules/@ponder/core/node_modules/better-sqlite3', 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' ] TOUCH ba23eeee118cd63e16015df367567cb043fed872.intermediate ACTION deps_sqlite3_gyp_locate_sqlite3_target_copy_builtin_sqlite3 ba23eeee118cd63e16015df367567cb043fed872.intermediate TOUCH Release/obj.target/deps/locate_sqlite3.stamp CC(target) Release/obj.target/sqlite3/gen/sqlite3/sqlite3.o LIBTOOL-STATIC Release/sqlite3.a CXX(target) Release/obj.target/better_sqlite3/src/better_sqlite3.o In file included from ../src/better_sqlite3.cpp:4: In file included from ./src/better_sqlite3.lzz:11: In file included from /Users/kevinkoste/Library/Caches/node-gyp/20.3.1/include/node/node.h:73: In file included from /Users/kevinkoste/Library/Caches/node-gyp/20.3.1/include/node/v8.h:24: In file included from /Users/kevinkoste/Library/Caches/node-gyp/20.3.1/include/node/v8-array-buffer.h:12: In file included from /Users/kevinkoste/Library/Caches/node-gyp/20.3.1/include/node/v8-local-handle.h:12: /Users/kevinkoste/Library/Caches/node-gyp/20.3.1/include/node/v8-internal.h:465:30: warning: 'static_assert' with no message is a C++17 extension [-Wc++17-extensions] SHARED_EXTERNAL_POINTER_TAGS(CHECK_SHARED_EXTERNAL_POINTER_TAGS) ^ /Users/kevinkoste/Library/Caches/node-gyp/20.3.1/include/node/v8-internal.h:465:30: warning: 'static_assert' with no message is a C++17 extension [-Wc++17-extensions] /Users/kevinkoste/Library/Caches/node-gyp/20.3.1/include/node/v8-internal.h:465:30: warning: 'static_assert' with no message is a C++17 extension [-Wc++17-extensions] /Users/kevinkoste/Library/Caches/node-gyp/20.3.1/include/node/v8-internal.h:465:30: warning: 'static_assert' with no message is a C++17 extension [-Wc++17-extensions] /Users/kevinkoste/Library/Caches/node-gyp/20.3.1/include/node/v8-internal.h:465:30: warning: 'static_assert' with no message is a C++17 extension [-Wc++17-extensions] /Users/kevinkoste/Library/Caches/node-gyp/20.3.1/include/node/v8-internal.h:466:35: warning: 'static_assert' with no message is a C++17 extension [-Wc++17-extensions] PER_ISOLATE_EXTERNAL_POINTER_TAGS(CHECK_NON_SHARED_EXTERNAL_POINTER_TAGS) ^ /Users/kevinkoste/Library/Caches/node-gyp/20.3.1/include/node/v8-internal.h:466:35: warning: 'static_assert' with no message is a C++17 extension [-Wc++17-extensions] /Users/kevinkoste/Library/Caches/node-gyp/20.3.1/include/node/v8-internal.h:466:35: warning: 'static_assert' with no message is a C++17 extension [-Wc++17-extensions] /Users/kevinkoste/Library/Caches/node-gyp/20.3.1/include/node/v8-internal.h:466:35: warning: 'static_assert' with no message is a C++17 extension [-Wc++17-extensions] /Users/kevinkoste/Library/Caches/node-gyp/20.3.1/include/node/v8-internal.h:466:35: warning: 'static_assert' with no message is a C++17 extension [-Wc++17-extensions] /Users/kevinkoste/Library/Caches/node-gyp/20.3.1/include/node/v8-internal.h:466:35: warning: 'static_assert' with no message is a C++17 extension [-Wc++17-extensions] /Users/kevinkoste/Library/Caches/node-gyp/20.3.1/include/node/v8-internal.h:466:35: warning: 'static_assert' with no message is a C++17 extension [-Wc++17-extensions] /Users/kevinkoste/Library/Caches/node-gyp/20.3.1/include/node/v8-internal.h:466:35: warning: 'static_assert' with no message is a C++17 extension [-Wc++17-extensions] /Users/kevinkoste/Library/Caches/node-gyp/20.3.1/include/node/v8-internal.h:466:35: warning: 'static_assert' with no message is a C++17 extension [-Wc++17-extensions] /Users/kevinkoste/Library/Caches/node-gyp/20.3.1/include/node/v8-internal.h:466:35: warning: 'static_assert' with no message is a C++17 extension [-Wc++17-extensions] /Users/kevinkoste/Library/Caches/node-gyp/20.3.1/include/node/v8-internal.h:466:35: warning: 'static_assert' with no message is a C++17 extension [-Wc++17-extensions] /Users/kevinkoste/Library/Caches/node-gyp/20.3.1/include/node/v8-internal.h:466:35: warning: 'static_assert' with no message is a C++17 extension [-Wc++17-extensions] /Users/kevinkoste/Library/Caches/node-gyp/20.3.1/include/node/v8-internal.h:693:61: warning: 'static_assert' with no message is a C++17 extension [-Wc++17-extensions] static_assert(kJSObjectType + 1 == kFirstJSApiObjectType); ^ , "" /Users/kevinkoste/Library/Caches/node-gyp/20.3.1/include/node/v8-internal.h:694:55: warning: 'static_assert' with no message is a C++17 extension [-Wc++17-extensions] static_assert(kJSObjectType < kLastJSApiObjectType); ^ , "" /Users/kevinkoste/Library/Caches/node-gyp/20.3.1/include/node/v8-internal.h:695:63: warning: 'static_assert' with no message is a C++17 extension [-Wc++17-extensions] static_assert(kFirstJSApiObjectType < kLastJSApiObjectType); ^ , "" In file included from ../src/better_sqlite3.cpp:4: In file included from ./src/better_sqlite3.lzz:11: In file included from /Users/kevinkoste/Library/Caches/node-gyp/20.3.1/include/node/node.h:73: In file included from /Users/kevinkoste/Library/Caches/node-gyp/20.3.1/include/node/v8.h:24: In file included from /Users/kevinkoste/Library/Caches/node-gyp/20.3.1/include/node/v8-array-buffer.h:13: In file included from /Users/kevinkoste/Library/Caches/node-gyp/20.3.1/include/node/v8-object.h:9: /Users/kevinkoste/Library/Caches/node-gyp/20.3.1/include/node/v8-maybe.h:106:45: error: no template named 'is_lvalue_reference_v' in namespace 'std'; did you mean 'is_lvalue_reference'? template >*> ~~~~~^~~~~~~~~~~~~~~~~~~~~ is_lvalue_reference /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/type_traits:910:29: note: 'is_lvalue_reference' declared here struct _LIBCPP_TEMPLATE_VIS is_lvalue_reference : _BoolConstant<__is_lvalue_reference(_Tp)> { }; ^ In file included from ../src/better_sqlite3.cpp:4: In file included from ./src/better_sqlite3.lzz:11: In file included from /Users/kevinkoste/Library/Caches/node-gyp/20.3.1/include/node/node.h:73: In file included from /Users/kevinkoste/Library/Caches/node-gyp/20.3.1/include/node/v8.h:24: In file included from /Users/kevinkoste/Library/Caches/node-gyp/20.3.1/include/node/v8-array-buffer.h:13: In file included from /Users/kevinkoste/Library/Caches/node-gyp/20.3.1/include/node/v8-object.h:9: /Users/kevinkoste/Library/Caches/node-gyp/20.3.1/include/node/v8-maybe.h:106:69: error: expected '(' for function-style cast or type construction template >*> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^ /Users/kevinkoste/Library/Caches/node-gyp/20.3.1/include/node/v8-maybe.h:123:43: error: no template named 'is_lvalue_reference_v' in namespace 'std'; did you mean 'is_lvalue_reference'? template >* = nullptr> ~~~~~^~~~~~~~~~~~~~~~~~~~~ is_lvalue_reference /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/type_traits:910:29: note: 'is_lvalue_reference' declared here struct _LIBCPP_TEMPLATE_VIS is_lvalue_reference : _BoolConstant<__is_lvalue_reference(_Tp)> { }; ^ In file included from ../src/better_sqlite3.cpp:4: In file included from ./src/better_sqlite3.lzz:11: In file included from /Users/kevinkoste/Library/Caches/node-gyp/20.3.1/include/node/node.h:73: In file included from /Users/kevinkoste/Library/Caches/node-gyp/20.3.1/include/node/v8.h:24: In file included from /Users/kevinkoste/Library/Caches/node-gyp/20.3.1/include/node/v8-array-buffer.h:13: In file included from /Users/kevinkoste/Library/Caches/node-gyp/20.3.1/include/node/v8-object.h:9: /Users/kevinkoste/Library/Caches/node-gyp/20.3.1/include/node/v8-maybe.h:123:67: error: expected '(' for function-style cast or type construction template >* = nullptr> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^ In file included from ../src/better_sqlite3.cpp:4: In file included from ./src/better_sqlite3.lzz:11: In file included from /Users/kevinkoste/Library/Caches/node-gyp/20.3.1/include/node/node.h:73: In file included from /Users/kevinkoste/Library/Caches/node-gyp/20.3.1/include/node/v8.h:33: In file included from /Users/kevinkoste/Library/Caches/node-gyp/20.3.1/include/node/v8-function.h:11: /Users/kevinkoste/Library/Caches/node-gyp/20.3.1/include/node/v8-function-callback.h:151:66: warning: 'static_assert' with no message is a C++17 extension [-Wc++17-extensions] kReturnValueDefaultValueIndex - kReturnValueIndex); ^ , "" /Users/kevinkoste/Library/Caches/node-gyp/20.3.1/include/node/v8-function-callback.h:153:50: warning: 'static_assert' with no message is a C++17 extension [-Wc++17-extensions] kIsolateIndex - kReturnValueIndex); ^ , "" ./src/util/macros.lzz:157:21: error: no member named 'AccessorSignature' in namespace 'v8' v8::AccessorSignature::New(isolate, recv) ~~~~^ ./src/objects/database.lzz:180:21: warning: variable 'status' set but not used [-Wunused-but-set-variable] int status = sqlite3_db_config(db_handle, SQLITE_DBCONFIG_ENABLE_LOAD_EXTENSION, 1, NULL); ^ ./src/util/binder.lzz:37:51: error: no member named 'CreationContext' in 'v8::Object' v8::Local ctx = obj->CreationContext(); ~~~~~^ 23 warnings and 6 errors generated. make: *** [Release/obj.target/better_sqlite3/src/better_sqlite3.o] Error 1 rm ba23eeee118cd63e16015df367567cb043fed872.intermediate gyp ERR! build error gyp ERR! stack Error: `make` failed with exit code: 2 gyp ERR! stack at ChildProcess.onExit (/Users/kevinkoste/.nvm/versions/node/v20.3.1/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:203:23) gyp ERR! stack at ChildProcess.emit (node:events:511:28) gyp ERR! stack at ChildProcess._handle.onexit (node:internal/child_process:293:12) gyp ERR! System Darwin 21.6.0 gyp ERR! command "/Users/kevinkoste/.nvm/versions/node/v20.3.1/bin/node" "/Users/kevinkoste/.nvm/versions/node/v20.3.1/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild" "--release" gyp ERR! cwd /Users/kevinkoste/workspace/tmp/npm-test/node_modules/@ponder/core/node_modules/better-sqlite3 gyp ERR! node -v v20.3.1 gyp ERR! node-gyp -v v9.3.1 gyp ERR! not ok at ProcessTermError.ExtendableBuiltin (/Users/kevinkoste/Library/pnpm/global/5/.pnpm/yarn@1.22.19/node_modules/yarn/lib/cli.js:721:66) at ProcessTermError.MessageError (/Users/kevinkoste/Library/pnpm/global/5/.pnpm/yarn@1.22.19/node_modules/yarn/lib/cli.js:750:123) at new ProcessTermError (/Users/kevinkoste/Library/pnpm/global/5/.pnpm/yarn@1.22.19/node_modules/yarn/lib/cli.js:790:113) at ChildProcess. (/Users/kevinkoste/Library/pnpm/global/5/.pnpm/yarn@1.22.19/node_modules/yarn/lib/cli.js:25787:17) at ChildProcess.emit (node:events:511:28) at maybeClose (node:internal/child_process:1098:16) at Socket. (node:internal/child_process:456:11) at Socket.emit (node:events:511:28) at Pipe. (node:net:334:12) error /Users/kevinkoste/workspace/tmp/npm-test/node_modules/@ponder/core/node_modules/better-sqlite3: Command failed. Exit code: 1 Command: prebuild-install || npm run build-release Arguments: Directory: /Users/kevinkoste/workspace/tmp/npm-test/node_modules/@ponder/core/node_modules/better-sqlite3 Output: prebuild-install warn install No prebuilt binaries found (target=20.3.1 runtime=node arch=arm64 libc= platform=darwin) > better-sqlite3@7.6.2 build-release > node-gyp rebuild --release gyp info it worked if it ends with ok gyp info using node-gyp@9.3.1 gyp info using node@20.3.1 | darwin | arm64 gyp info find Python using Python version 3.9.6 found at "/Library/Developer/CommandLineTools/usr/bin/python3" gyp info spawn /Library/Developer/CommandLineTools/usr/bin/python3 gyp info spawn args [ gyp info spawn args '/Users/kevinkoste/.nvm/versions/node/v20.3.1/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 '/Users/kevinkoste/workspace/tmp/npm-test/node_modules/@ponder/core/node_modules/better-sqlite3/build/config.gypi', gyp info spawn args '-I', gyp info spawn args '/Users/kevinkoste/.nvm/versions/node/v20.3.1/lib/node_modules/npm/node_modules/node-gyp/addon.gypi', gyp info spawn args '-I', gyp info spawn args '/Users/kevinkoste/Library/Caches/node-gyp/20.3.1/include/node/common.gypi', gyp info spawn args '-Dlibrary=shared_library', gyp info spawn args '-Dvisibility=default', gyp info spawn args '-Dnode_root_dir=/Users/kevinkoste/Library/Caches/node-gyp/20.3.1', gyp info spawn args '-Dnode_gyp_dir=/Users/kevinkoste/.nvm/versions/node/v20.3.1/lib/node_modules/npm/node_modules/node-gyp', gyp info spawn args '-Dnode_lib_file=/Users/kevinkoste/Library/Caches/node-gyp/20.3.1/<(target_arch)/node.lib', gyp info spawn args '-Dmodule_root_dir=/Users/kevinkoste/workspace/tmp/npm-test/node_modules/@ponder/core/node_modules/better-sqlite3', 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' ] TOUCH ba23eeee118cd63e16015df367567cb043fed872.intermediate ACTION deps_sqlite3_gyp_locate_sqlite3_target_copy_builtin_sqlite3 ba23eeee118cd63e16015df367567cb043fed872.intermediate TOUCH Release/obj.target/deps/locate_sqlite3.stamp CC(target) Release/obj.target/sqlite3/gen/sqlite3/sqlite3.o LIBTOOL-STATIC Release/sqlite3.a CXX(target) Release/obj.target/better_sqlite3/src/better_sqlite3.o In file included from ../src/better_sqlite3.cpp:4: In file included from ./src/better_sqlite3.lzz:11: In file included from /Users/kevinkoste/Library/Caches/node-gyp/20.3.1/include/node/node.h:73: In file included from /Users/kevinkoste/Library/Caches/node-gyp/20.3.1/include/node/v8.h:24: In file included from /Users/kevinkoste/Library/Caches/node-gyp/20.3.1/include/node/v8-array-buffer.h:12: In file included from /Users/kevinkoste/Library/Caches/node-gyp/20.3.1/include/node/v8-local-handle.h:12: /Users/kevinkoste/Library/Caches/node-gyp/20.3.1/include/node/v8-internal.h:465:30: warning: 'static_assert' with no message is a C++17 extension [-Wc++17-extensions] SHARED_EXTERNAL_POINTER_TAGS(CHECK_SHARED_EXTERNAL_POINTER_TAGS) ^ /Users/kevinkoste/Library/Caches/node-gyp/20.3.1/include/node/v8-internal.h:465:30: warning: 'static_assert' with no message is a C++17 extension [-Wc++17-extensions] /Users/kevinkoste/Library/Caches/node-gyp/20.3.1/include/node/v8-internal.h:465:30: warning: 'static_assert' with no message is a C++17 extension [-Wc++17-extensions] /Users/kevinkoste/Library/Caches/node-gyp/20.3.1/include/node/v8-internal.h:465:30: warning: 'static_assert' with no message is a C++17 extension [-Wc++17-extensions] /Users/kevinkoste/Library/Caches/node-gyp/20.3.1/include/node/v8-internal.h:465:30: warning: 'static_assert' with no message is a C++17 extension [-Wc++17-extensions] /Users/kevinkoste/Library/Caches/node-gyp/20.3.1/include/node/v8-internal.h:466:35: warning: 'static_assert' with no message is a C++17 extension [-Wc++17-extensions] PER_ISOLATE_EXTERNAL_POINTER_TAGS(CHECK_NON_SHARED_EXTERNAL_POINTER_TAGS) ^ /Users/kevinkoste/Library/Caches/node-gyp/20.3.1/include/node/v8-internal.h:466:35: warning: 'static_assert' with no message is a C++17 extension [-Wc++17-extensions] /Users/kevinkoste/Library/Caches/node-gyp/20.3.1/include/node/v8-internal.h:466:35: warning: 'static_assert' with no message is a C++17 extension [-Wc++17-extensions] /Users/kevinkoste/Library/Caches/node-gyp/20.3.1/include/node/v8-internal.h:466:35: warning: 'static_assert' with no message is a C++17 extension [-Wc++17-extensions] /Users/kevinkoste/Library/Caches/node-gyp/20.3.1/include/node/v8-internal.h:466:35: warning: 'static_assert' with no message is a C++17 extension [-Wc++17-extensions] /Users/kevinkoste/Library/Caches/node-gyp/20.3.1/include/node/v8-internal.h:466:35: warning: 'static_assert' with no message is a C++17 extension [-Wc++17-extensions] /Users/kevinkoste/Library/Caches/node-gyp/20.3.1/include/node/v8-internal.h:466:35: warning: 'static_assert' with no message is a C++17 extension [-Wc++17-extensions] /Users/kevinkoste/Library/Caches/node-gyp/20.3.1/include/node/v8-internal.h:466:35: warning: 'static_assert' with no message is a C++17 extension [-Wc++17-extensions] /Users/kevinkoste/Library/Caches/node-gyp/20.3.1/include/node/v8-internal.h:466:35: warning: 'static_assert' with no message is a C++17 extension [-Wc++17-extensions] /Users/kevinkoste/Library/Caches/node-gyp/20.3.1/include/node/v8-internal.h:466:35: warning: 'static_assert' with no message is a C++17 extension [-Wc++17-extensions] /Users/kevinkoste/Library/Caches/node-gyp/20.3.1/include/node/v8-internal.h:466:35: warning: 'static_assert' with no message is a C++17 extension [-Wc++17-extensions] /Users/kevinkoste/Library/Caches/node-gyp/20.3.1/include/node/v8-internal.h:466:35: warning: 'static_assert' with no message is a C++17 extension [-Wc++17-extensions] /Users/kevinkoste/Library/Caches/node-gyp/20.3.1/include/node/v8-internal.h:693:61: warning: 'static_assert' with no message is a C++17 extension [-Wc++17-extensions] static_assert(kJSObjectType + 1 == kFirstJSApiObjectType); ^ , "" /Users/kevinkoste/Library/Caches/node-gyp/20.3.1/include/node/v8-internal.h:694:55: warning: 'static_assert' with no message is a C++17 extension [-Wc++17-extensions] static_assert(kJSObjectType < kLastJSApiObjectType); ^ , "" /Users/kevinkoste/Library/Caches/node-gyp/20.3.1/include/node/v8-internal.h:695:63: warning: 'static_assert' with no message is a C++17 extension [-Wc++17-extensions] static_assert(kFirstJSApiObjectType < kLastJSApiObjectType); ^ , "" In file included from ../src/better_sqlite3.cpp:4: In file included from ./src/better_sqlite3.lzz:11: In file included from /Users/kevinkoste/Library/Caches/node-gyp/20.3.1/include/node/node.h:73: In file included from /Users/kevinkoste/Library/Caches/node-gyp/20.3.1/include/node/v8.h:24: In file included from /Users/kevinkoste/Library/Caches/node-gyp/20.3.1/include/node/v8-array-buffer.h:13: In file included from /Users/kevinkoste/Library/Caches/node-gyp/20.3.1/include/node/v8-object.h:9: /Users/kevinkoste/Library/Caches/node-gyp/20.3.1/include/node/v8-maybe.h:106:45: error: no template named 'is_lvalue_reference_v' in namespace 'std'; did you mean 'is_lvalue_reference'? template >*> ~~~~~^~~~~~~~~~~~~~~~~~~~~ is_lvalue_reference /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/type_traits:910:29: note: 'is_lvalue_reference' declared here struct _LIBCPP_TEMPLATE_VIS is_lvalue_reference : _BoolConstant<__is_lvalue_reference(_Tp)> { }; ^ In file included from ../src/better_sqlite3.cpp:4: In file included from ./src/better_sqlite3.lzz:11: In file included from /Users/kevinkoste/Library/Caches/node-gyp/20.3.1/include/node/node.h:73: In file included from /Users/kevinkoste/Library/Caches/node-gyp/20.3.1/include/node/v8.h:24: In file included from /Users/kevinkoste/Library/Caches/node-gyp/20.3.1/include/node/v8-array-buffer.h:13: In file included from /Users/kevinkoste/Library/Caches/node-gyp/20.3.1/include/node/v8-object.h:9: /Users/kevinkoste/Library/Caches/node-gyp/20.3.1/include/node/v8-maybe.h:106:69: error: expected '(' for function-style cast or type construction template >*> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^ /Users/kevinkoste/Library/Caches/node-gyp/20.3.1/include/node/v8-maybe.h:123:43: error: no template named 'is_lvalue_reference_v' in namespace 'std'; did you mean 'is_lvalue_reference'? template >* = nullptr> ~~~~~^~~~~~~~~~~~~~~~~~~~~ is_lvalue_reference /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/type_traits:910:29: note: 'is_lvalue_reference' declared here struct _LIBCPP_TEMPLATE_VIS is_lvalue_reference : _BoolConstant<__is_lvalue_reference(_Tp)> { }; ^ In file included from ../src/better_sqlite3.cpp:4: In file included from ./src/better_sqlite3.lzz:11: In file included from /Users/kevinkoste/Library/Caches/node-gyp/20.3.1/include/node/node.h:73: In file included from /Users/kevinkoste/Library/Caches/node-gyp/20.3.1/include/node/v8.h:24: In file included from /Users/kevinkoste/Library/Caches/node-gyp/20.3.1/include/node/v8-array-buffer.h:13: In file included from /Users/kevinkoste/Library/Caches/node-gyp/20.3.1/include/node/v8-object.h:9: /Users/kevinkoste/Library/Caches/node-gyp/20.3.1/include/node/v8-maybe.h:123:67: error: expected '(' for function-style cast or type construction template >* = nullptr> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^ In file included from ../src/better_sqlite3.cpp:4: In file included from ./src/better_sqlite3.lzz:11: In file included from /Users/kevinkoste/Library/Caches/node-gyp/20.3.1/include/node/node.h:73: In file included from /Users/kevinkoste/Library/Caches/node-gyp/20.3.1/include/node/v8.h:33: In file included from /Users/kevinkoste/Library/Caches/node-gyp/20.3.1/include/node/v8-function.h:11: /Users/kevinkoste/Library/Caches/node-gyp/20.3.1/include/node/v8-function-callback.h:151:66: warning: 'static_assert' with no message is a C++17 extension [-Wc++17-extensions] kReturnValueDefaultValueIndex - kReturnValueIndex); ^ , "" /Users/kevinkoste/Library/Caches/node-gyp/20.3.1/include/node/v8-function-callback.h:153:50: warning: 'static_assert' with no message is a C++17 extension [-Wc++17-extensions] kIsolateIndex - kReturnValueIndex); ^ , "" ./src/util/macros.lzz:157:21: error: no member named 'AccessorSignature' in namespace 'v8' v8::AccessorSignature::New(isolate, recv) ~~~~^ ./src/objects/database.lzz:180:21: warning: variable 'status' set but not used [-Wunused-but-set-variable] int status = sqlite3_db_config(db_handle, SQLITE_DBCONFIG_ENABLE_LOAD_EXTENSION, 1, NULL); ^ ./src/util/binder.lzz:37:51: error: no member named 'CreationContext' in 'v8::Object' v8::Local ctx = obj->CreationContext(); ~~~~~^ 23 warnings and 6 errors generated. make: *** [Release/obj.target/better_sqlite3/src/better_sqlite3.o] Error 1 rm ba23eeee118cd63e16015df367567cb043fed872.intermediate gyp ERR! build error gyp ERR! stack Error: `make` failed with exit code: 2 gyp ERR! stack at ChildProcess.onExit (/Users/kevinkoste/.nvm/versions/node/v20.3.1/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:203:23) gyp ERR! stack at ChildProcess.emit (node:events:511:28) gyp ERR! stack at ChildProcess._handle.onexit (node:internal/child_process:293:12) gyp ERR! System Darwin 21.6.0 gyp ERR! command "/Users/kevinkoste/.nvm/versions/node/v20.3.1/bin/node" "/Users/kevinkoste/.nvm/versions/node/v20.3.1/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild" "--release" gyp ERR! cwd /Users/kevinkoste/workspace/tmp/npm-test/node_modules/@ponder/core/node_modules/better-sqlite3 gyp ERR! node -v v20.3.1 gyp ERR! node-gyp -v v9.3.1 gyp ERR! not ok ```

Questions:

  1. It seems clear that the prebuilt binaries are not being found for any of the package managers. Any idea why? It really seems like my platform should be supported. The Yarn/Node 18 logs show a warning from prebuild-install that doesn't make sense to me: verbose 19.852559167 prebuild-install warn install No prebuilt binaries found (target=18.16.1 runtime=node arch=arm64 libc= platform=darwin).
  2. For a given installation, is there any way to tell if the prebuilt binary is being used or if it was built from source? Perhaps by inspecting the files in node_modules/better-sqlite3?
neoxpert commented 1 year ago

Well regarding the observation of point 4: That is correct and expected. There have been changes in the Node API and the required adjustments were introduced with better-sqlite3@8.0.0. For version 7.6.2 there are no prebuilt binaries available for the combination of arm64 and darwin. What makes it strange, because you said, that you were able to install it before installing node-gyp?

Afaik there is no other way than looking in the install output to determine if a prebuilt module is being used or if it was built from source - beside afterwards checking if there are any other files present under node_modules/better-slite3/build/Release than the better_sqlite3.node file.

0xOlias commented 1 year ago

What makes it strange, because you said, that you were able to install it before installing node-gyp?

EDIT: This is indeed strange. I have a hunch that (many months ago) I built better-sqlite3 from source on my machine, and it was added to the pnpm cache/store. And then at some point I may have uninstalled node-gyp.

Thanks for the tip on checking node_modules/better-slite3/build/Release. There are other files present in that dir everywhere I've tried to install it, so (as expected) it's being built from source in every case.

Any idea why prebuild-install is not able to find the prebuilt binaries for my machine? Or how I can debug this further?

neoxpert commented 1 year ago

Well which prebuilts? If you are still trying to use 7.6.2 -> There are none available for your machine architecture. If prebuilt-install does not find prebuilt binaries for 8.4.0 that would be strange and I don't think it could be solved by better-sqlite3 alone. So far I did not encounter this issue on multiple automated build platforms (win x64, darwin x64 and darwin arm64).

ImSingee commented 1 year ago

For a workaround, just run pnpm install -g node-gyp before install better-sqlite3.

Wolfr commented 1 year ago

@ImSingee running this command first helped me out of a pickle when installing supabase, which also seems to depend on better-sqlite3 (in a Sveltekit context). Thank you.