Open 0xOlias opened 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.
Thanks for the response. I did some more digging:
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.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.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).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)Questions:
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)
.node_modules/better-sqlite3
?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.
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?
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).
For a workaround, just run pnpm install -g node-gyp
before install better-sqlite3.
@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.
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:
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: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)
forbetter-sqlite3@8.4.0
.