vlcn-io / vite-starter

scaffold for a vitejs based vlcn project
32 stars 6 forks source link

Binaries for `better_sqlite.node` and `crsqlite.dylib` on `arm64` architecture #25

Open Sheraff opened 8 months ago

Sheraff commented 8 months ago

Trying to start the project in a very naive manner, just pnpm i and pnpm dev did not start sqlite. I got the following error

Error: dlopen(/Users/Flo/GitHub/vulcan-test/node_modules/.pnpm/better-sqlite3@8.6.0/node_modules/better-sqlite3/build/Release/better_sqlite3.node, 0x0001): 
  tried: 
    '[repo]/node_modules/.pnpm/better-sqlite3@8.6.0/node_modules/better-sqlite3/build/Release/better_sqlite3.node' 
      (mach-o file, but is an incompatible architecture (have 'x86_64', need 'arm64')), 
    '/System/Volumes/Preboot/Cryptexes/OS/[repo]/node_modules/.pnpm/better-sqlite3@8.6.0/node_modules/better-sqlite3/build/Release/better_sqlite3.node' 
      (no such file), 
    '[repo]/node_modules/.pnpm/better-sqlite3@8.6.0/node_modules/better-sqlite3/build/Release/better_sqlite3.node' 
      (mach-o file, but is an incompatible architecture (have 'x86_64', need 'arm64'))

I managed to bypass this issue by manually downloading the arm64 binary from https://github.com/WiseLibs/better-sqlite3/releases and replacing it inside [repo]/node_modules/.pnpm/better-sqlite3@8.6.0/node_modules/better-sqlite3/build/Release/better_sqlite.node.

I then had a very similar issue for crsqlite.dylib so I downloaded crsqlite-darwin-aarch64.dylib and replaced it inside [repo]/node_modules/.pnpm/@vlcn.io+crsqlite@0.15.1/node_modules/@vlcn.io/crsqlite/dist/crsqlite.dylib


I'm not used to working with node modules that download binaries (or maybe I am and I just never noticed). Is there a way to make it so that the correct architecture is automatically downloaded?

tantaman commented 7 months ago

It tries to detect and download the correct binary during installation here:

https://github.com/vlcn-io/cr-sqlite/blob/0a38408bf2f8c32c6950120da4dbb70b131d8d9c/core/nodejs-install-helper.js#L44-L51

It must not have correctly detected the host architecture.

What sort of machine and os are you on?

Sheraff commented 7 months ago

I'm on macbook M3, macos sonoma, node 20. I can retry an install, or give you other stats if that helps. I really want to build stuff with crsqlite!

tantaman commented 7 months ago

Can you try scaffolding a new project and share the output?

The script command is useful for this.

> script my-session
> do you stuff...
> Ctrl+d

and it'll create a text file called my-session with the input and output of your terminal session.

Sheraff commented 7 months ago

Hmmm... it worked this time... And as far as I can tell I didn't do anything different (I tried installing from the native terminal, and from vscode's since I know it doesn't open the same user profile). I'll keep you posted if I encounter this again. Issue can probably be closed in the meantime.